angular(2+)报错处理之 -- 关于function 、lambda、not supported等

错误信息
ERROR in Error: Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 194:50 in
 the original .ts file), resolving symbol NgModule in D:/plateform/project-test/node_modules/@angular/platform-browser/node_modules/@angular/core/core.d.ts, resolving symbol BrowserModule in D:/plateform/pr
oject-test/node_modules/@angular/platform-browser/platform-browser.d.ts, resolving symbol BrowserModule in D:/plateform/project-test/node_modules/@angular/platform-browser/platform-browser.d.ts
    at positionalError (D:\plateform\project-test\node_modules\.4.4.3@@angular\compiler\bundles\compiler.umd.js:25266:35)
    at simplifyInContext (D:\plateform\project-test\node_modules\.4.4.3@@angular\compiler\bundles\compiler.umd.js:25109:27)
    at StaticReflector.simplify (D:\plateform\project-test\node_modules\.4.4.3@@angular\compiler\bundles\compiler.umd.js:25123:13)
    at StaticReflector.annotations (D:\plateform\project-test\node_modules\.4.4.3@@angular\compiler\bundles\compiler.umd.js:24553:41)
    at _getNgModuleMetadata (D:\plateform\project-test\node_modules\.4.4.3@@angular\compiler-cli\src\ngtools_impl.js:138:31)
    at _extractLazyRoutesFromStaticModule (D:\plateform\project-test\node_modules\.4.4.3@@angular\compiler-cli\src\ngtools_impl.js:109:26)
    at D:\plateform\project-test\node_modules\.4.4.3@@angular\compiler-cli\src\ngtools_impl.js:129:27
    at Array.reduce (native)
    at _extractLazyRoutesFromStaticModule (D:\plateform\project-test\node_modules\.4.4.3@@angular\compiler-cli\src\ngtools_impl.js:128:10)
    at Object.listLazyRoutesOfModule (D:\plateform\project-test\node_modules\.4.4.3@@angular\compiler-cli\src\ngtools_impl.js:53:22)
    at Function.NgTools_InternalApi_NG_2.listLazyRoutes (D:\plateform\project-test\node_modules\.4.4.3@@angular\compiler-cli\src\ngtools_api.js:91:39)
    at AotPlugin._getLazyRoutesFromNgtools (D:\plateform\project-test\node_modules\.1.7.1@@ngtools\webpack\src\plugin.js:207:44)
    at _donePromise.Promise.resolve.then.then.then.then.then (D:\plateform\project-test\node_modules\.1.7.1@@ngtools\webpack\src\plugin.js:443:24)
    at process._tickCallback (internal/process/next_tick.js:109:7)
复制代码
解决办法

它是typescript的依赖关系问题,在 tsconfig.json文件中中加

"paths": {
      "@angular/common": ["../node_modules/@angular/common"],
      "@angular/compiler": ["../node_modules/@angular/compiler"],
      "@angular/core": ["../node_modules/@angular/core"],
      "@angular/forms": ["../node_modules/@angular/forms"],
      "@angular/platform-browser": ["../node_modules/@angular/platform-browser"],
      "@angular/platform-browser-dynamic": ["../node_modules/@angular/platform-browser-dynamic"],
      "@angular/router": ["../node_modules/@angular/router"],
      "@angular/http": ["../node_modules/@angular/http"]
    }
复制代码

加后形如这样:

{
  "compilerOptions": {
    "baseUrl": "",
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es6", "dom"],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ],
    "paths": {
      "@angular/common": ["../node_modules/@angular/common"],
      "@angular/compiler": ["../node_modules/@angular/compiler"],
      "@angular/core": ["../node_modules/@angular/core"],
      "@angular/forms": ["../node_modules/@angular/forms"],
      "@angular/platform-browser": ["../node_modules/@angular/platform-browser"],
      "@angular/platform-browser-dynamic": ["../node_modules/@angular/platform-browser-dynamic"],
      "@angular/router": ["../node_modules/@angular/router"],
      "@angular/http": ["../node_modules/@angular/http"]
    }
  }
}

复制代码

| 更多报错处理更新于 github

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值