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的版本有关。

  • 相关阅读:
    手写Linq To Object
    4、IOC--内置Unity容器的使用
    WebApi 基于JWT实现Token签名认证
    软件架构师之路--观察者模式
    EF--封装三层架构IOC
    EF--主外键关系导航属性
    EF--EntityState相互转换
    证明task线程是来源于线程池的,线程重用
    3、IOC--手写Unity容器--链式依赖--第N层依赖注入
    2、IOC--手写Unity容器--第一层依赖注入
  • 原文地址:https://www.cnblogs.com/viola-sh/p/10115246.html
Copyright © 2011-2022 走看看