首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Angular 8使用常春藤module.ngfactory找不到

Angular 8使用常春藤module.ngfactory找不到
EN

Stack Overflow用户
提问于 2019-05-29 20:46:49
回答 2查看 1.1K关注 0票数 0

我有一个片段:

代码语言:javascript
复制
import { platformBrowser }    from '@angular/platform-browser';
import { enableProdMode } from '@angular/core';
enableProdMode();

import '../../../src/bundle';

import {ModuleNgFactory} from './module.ngfactory';

platformBrowser().bootstrapModuleFactory(ModuleNgFactory);

一旦我启用了ivy,我就会遇到这样的错误:

代码语言:javascript
复制
Running "cory-build-aot" task

Compiling @angular/core : module as esm5

Compiling @angular/common : module as esm5

Compiling @angular/platform-browser : module as esm5

Compiling @angular/common/http : module as esm5

Compiling @angular/router : module as esm5

Compiling @angular/forms : module as esm5
Hash: d7163c5eb0d56ede4ba6
Version: webpack 4.32.2
Time: 24870ms
Built at: 05/29/2019 2:43:19 PM
 4 assets
Entrypoint polyfills = polyfills.d7163c5eb0d56ede4ba6.js sourcemaps/polyfills.d7163c5eb0d56ede4ba6.js.map
Entrypoint bundle = bundle.d7163c5eb0d56ede4ba6.js sourcemaps/bundle.d7163c5eb0d56ede4ba6.js.map
[0] ./test/angular-webpack/angular/polyfills.ts 0 bytes {1} [built]
[1] ./test/angular-webpack/angular/bundle.aot.ts 0 bytes {0} [built]

ERROR in test/angular-webpack/angular/bundle.aot.ts(7,31): error TS2307: Cannot find module './module.ngfactory'.

Child html-webpack-plugin for "index.html":
     1 asset
    Entrypoint undefined = index.html
    [0] ./node_modules/html-webpack-plugin/lib/loader.js!./test/angular-webpack/index.html 261 bytes {0} [built]
Warning: Command failed: ./node_modules/.bin/webpack-cli --color --cache --production --config /home/patrikx3/Projects/patrikx3/corifeus/corifeus-web/node_modules/corifeus-builder-angular/src/webpack.test.config.js

Compiling @angular/core : module as esm5

Compiling @angular/common : module as esm5

Compiling @angular/platform-browser : module as esm5

Compiling @angular/common/http : module as esm5

Compiling @angular/router : module as esm5

Compiling @angular/forms : module as esm5
 Use --force to continue.

Aborted due to warnings.


Execution Time (2019-05-29 14:42:53 UTC+2)
cory-build-aot  25.8s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100%
Total 25.9s

patrikx3@workstation:~/Projects/patrikx3/corifeus/corifeus-web$ 

错误是: error in test/angular-webpack/angular/bundle.aot.ts(7,31):ERROR TS2307:找不到模块'./module.ngfactory‘。

我尝试通过将angularCompilerOptions部分添加到enableIvy来启用ivy,这就是我收到这个错误的时候。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-05-29 20:55:49

角常春藤不再有任何no工厂。

现在,信息作为静态字段存储在组件本身上,而不是将有关组件的元数据存储在单独的文件中。

因此,您应该重构您的代码,以不使用与ngfactory相关的东西,如导入./module.ngfactory

票数 2
EN

Stack Overflow用户

发布于 2019-05-29 20:57:51

需要在tsconfig.app.json的angularCompilerOptions中添加allowEmptyCodegenFiles : true

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56361024

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档