zoukankan      html  css  js  c++  java
  • 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的版本有关。

  • 相关阅读:
    Python面向对象——内置对象的功能扩展
    学术日记#学术道德与人文素养
    Python面向对象——基本继承
    SqlServer——字符串处理函数
    SqlServer——索引
    生活小问题(1)
    win7-VS2010-IIS网站的发布问题
    PhoneGap+Cordova+SenchaTouch-01-环境搭建
    sql server数字转字符串出现科学计数法
    SQLServer 重启服务后,自增1的标识列一次增长了1000(转自博问)
  • 原文地址:https://www.cnblogs.com/viola-sh/p/10115246.html
Copyright © 2011-2022 走看看