• ERROR in Error: ***Module is not an NgModule


     引入一个打包的模块时报了这个个错:

    $ rimraf out
    Done in 16.81s.
    lerna ERR! build Errored while running script in 'map'
    lerna ERR! execute callback with error
    lerna ERR! Error: Command failed: yarn run build
    lerna ERR! warning package.json: License should be a valid SPDX license expression
    lerna ERR! warning ../../../package.json: No license field
    lerna ERR! 
    lerna ERR! ERROR in Error: Ng2WindowModule is not an NgModule
    lerna ERR!     at _getNgModuleMetadata (/Users/machan/Desktop/workspace/office/trunk-web2.5/packages/ng-apps/map/node_modules/@angular/compiler-cli/src/ngtools_impl.js:140:15)
    lerna ERR!     at _extractLazyRoutesFromStaticModule (/Users/**/Desktop/workspace/office/trunk-web2.5/packages/ng-apps/map/node_modules/@angular/compiler-cli/src/ngtools_impl.js:109:26)
    lerna ERR!     at /Users/**/Desktop/workspace/office/trunk-web2.5/packages/ng-apps/map/node_modules/@angular/compiler-cli/src/ngtools_impl.js:129:27
    lerna ERR!     at Array.reduce (<anonymous>)
    lerna ERR!     at _extractLazyRoutesFromStaticModule (/Users/**/Desktop/workspace/office/trunk-web2.5/packages/ng-apps/map/node_modules/@angular/compiler-cli/src/ngtools_impl.js:128:10)
    lerna ERR!     at Object.listLazyRoutesOfModule (/Users/**/Desktop/workspace/office/trunk-web2.5/packages/ng-apps/map/node_modules/@angular/compiler-cli/src/ngtools_impl.js:53:22)
    lerna ERR!     at Function.NgTools_InternalApi_NG_2.listLazyRoutes (/Users/**/Desktop/workspace/office/trunk-web2.5/packages/ng-apps/map/node_modules/@angular/compiler-cli/src/ngtools_api.js:91:39)
    lerna ERR!     at AotPlugin._getLazyRoutesFromNgtools (/Users/**/Desktop/workspace/office/trunk-web2.5/packages/ng-apps/map/node_modules/@ngtools/webpack/src/plugin.js:240:66)
    lerna ERR!     at _donePromise.Promise.resolve.then.then.then.then.then (/Users/**/Desktop/workspace/office/trunk-web2.5/packages/ng-apps/map/node_modules/@ngtools/webpack/src/plugin.js:493:24)
    lerna ERR!     at <anonymous>
    lerna ERR! error Command failed with exit code 1.

     这个错跟AppModule is not a NgModule的原因不一样。

    试了很多方法,最后在tsconfig.json里面添加

    {
      ...
      "compilerOptions": {
     ...
        "paths": {
          ...
          "@**/ng2-window": ["../node_modules/@**/ng2-window/src"],
          "@**/ng2-property": ["../node_modules/@**/ng2-property/src"],
          "@**/ng-common": ["../node_modules/@**/ng-common/src"],
          "@**/ng-core": ["../node_modules/@**/ng-core/src"]
        }
      },
      "exclude": [
        ...
      ]
    }

    通过path的设置,来指定调用的模块路径。

    ------------------------------------------------------

    AppModule is not a NgModule的报错,原因很多是跟typescript或者angular的版本有关。

  • 相关阅读:
    手把手带你玩转 DialogFragment
    紧张的去京东面试7,没想到可以成功拿下offer
    这个有点强,MySQL常用优化指南及大表优化思路(值得收藏)
    Java程序员两年经验斩获头条 Offer,技术杠杠的
    为什么大家都说 SELECT * 效率低
    Java程序员想要靠外包刷题,结果却大跌眼镜,心态都崩了
    一次请求在SpringMVC核心执行流程
    工作三年经验,一年内我靠这份javaBAT进阶面试题从13K到大厂25K
    用了这么久的数据库连接池,你知道原理吗?
    poj 3295 Tautology(栈)
  • 原文地址:https://www.cnblogs.com/viola-sh/p/10115246.html
Copyright © 2020-2023  润新知