Angular 5: 为什么在调试模式下没有显示 'Component is part of the declaration of 2 modules'
Angular 5: Why in debug mode it's no show up 'Component is part of the declaration of 2 modules'
当我使用此命令 运行 调试模式时:npm run build
,我将拥有所有 dist 文件夹,我可以部署项目。
当我 运行 使用此命令进行生产时:npm run build -- --prod
,我将出现此错误 'Component is part of the declaration of 2 modules'。
我的问题是:为什么这两种模式之间存在差异?这是AOT选项引起的吗?
这只是 Angular 的提前编译。因为去掉了代码,所以比debug编译要严格很多,其他几个错误也只有AOT编译才报。
通常,出于这个原因,我会在提交之前执行 ng build -prod
(这意味着 AOT)。
由于您使用的是 npm
脚本,我会使用 @trichetriche 建议的语法:
npm run build -- --aot
当我使用此命令 运行 调试模式时:npm run build
,我将拥有所有 dist 文件夹,我可以部署项目。
当我 运行 使用此命令进行生产时:npm run build -- --prod
,我将出现此错误 'Component is part of the declaration of 2 modules'。
我的问题是:为什么这两种模式之间存在差异?这是AOT选项引起的吗?
这只是 Angular 的提前编译。因为去掉了代码,所以比debug编译要严格很多,其他几个错误也只有AOT编译才报。
通常,出于这个原因,我会在提交之前执行 ng build -prod
(这意味着 AOT)。
由于您使用的是 npm
脚本,我会使用 @trichetriche 建议的语法:
npm run build -- --aot