angular5 - _lazy_route_resource 惰性命名空间对象

标签 angular5 webpack-4 angular-aot angular-compiler

我正在使用角度编译器:const AngularCompilerPlugin = require('@ngtools/webpack').AngularCompilerPlugin;
使用这些编译器选项:

"angularCompilerOptions": {
"genDir": "./build/compiled",
"outDir": "./build/compiled",
"skipMetadataEmit": true,
"debug": true},

我的 package.json 的相关部分是:
"@ngtools/webpack": "^6.0.0",
"@angular/router": "^5.2.0",
"webpack": "4.8.3",
"webpack-cli": "2.1.4",

我的 angularCompilerPlugin 配置是:
new AngularCompilerPlugin({
  tsConfigPath: 'path-to-tsconfig.webpack.json',
  entryModule: 'path-to-app.module#AppModule',
  sourceMap: true
}),

使用这些配置,我得到:
ERROR in ./$$_lazy_route_resource lazy namespace object
Module not found: Error: Can't resolve 'path-/alerts/module.ngfactory.js' in 'path-to-app-folder/$$_lazy_route_resource'
 @ ./$$_lazy_route_resource lazy namespace object
 @ ./node_modules/@angular/core/esm5/core.js
 @ multi core-js/shim classlist.js reflect-metadata zone.js/dist/zone jquery/dist/jquery rxjs/Rx lodash jquery.panzoom moment moment-timezone @angular/common @angular/core @angular/http @angular/router @angular/forms semantic

请任何方向或帮助。

最佳答案

我能够通过添加延迟模块 .ts 来解决此错误我的 ts.config-aot.json 的路径在 files部分:

{
    "compilerOptions": {
        "target": "es5", //most browsers currently understand this version of Javascript
        "experimentalDecorators": true, //Angular2 uses Component,Injectable etc
        "emitDecoratorMetadata": true, //Required for Angular2 to use the metadata in our components
        "types": [
            "node",
            "jasmine"
        ],
        "lib": [
            "es2015",
            "es2015.iterable",
            "dom"
        ]
    },
    "exclude": [
        "node_modules"
    ],
    "files": [
        "src/app/app.module.ts",
        "src/main.ts",
        "src/app.d.ts",
        "src/app/sandbox/sandbox.module.ts",
        "src/app/supplier-xchange/supplier-xchange.module.ts",
        "src/app/company-profile/company-profile.module.ts",
        "src/app/bom/bom.module.ts",
        "src/app/custom-price-column/custom-price-column.module.ts",
        "src/app/neca/neca.module.ts"
    ]
}

关于angular5 - _lazy_route_resource 惰性命名空间对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50920491/

相关文章:

Angular HTTP POST 请求调用了 4 次

javascript - ngx-chips 自定义主题不起作用

helper - 带有 handlebars-loader 的自定义助手

启用 AoT 时,ActivatedRoute.snapshot 中的 Angular 路由 'data' 为空

angular - 在 Angular5 中使用 SockJS 时出错 - "sockjs_client_1.SockJS is not a constructor"

angular5 - 根据选择另一个 p-dropdown PrimeNG 禁用 p-dropdown

javascript - Babel 不编译 vendor 卡盘

angular - 升级到Webpack 4后,Angular Application中的InjectionToken Config否

javascript - 如何在 Angular 7 中输入路由数据(在生产中)?