未捕获的ReferenceError:require未定义Angular 5

时间:2018-05-07 11:10:53

标签: angular

angular / cli - 1.6.8

tsconfig.json

{
"compileOnSave": false,
"compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "allowJs": true,
    "noImplicitAny": false,
    "baseUrl": "./src",
    "module": "system",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
        // "./src/typings.d.ts",
        "node_modules/@types",
    ],
    "lib": [
        "es2017",
        "es2015",
        "dom",
        "es5",
        "es6",
    ],
},
"exclude": [
    "node_modules"
]}
.angular-cli.json app.scripts[0] = "../node_modules/json-rpc-protocol/dist/index.js";

1 个答案:

答案 0 :(得分:-2)

如果您尝试使用Google搜索...

在编译时,编译器不了解require。 将其声明为:

declare const require: any

应该有帮助。