build - Angular 5 错误:尝试从 node_modules /node_modules/ngx-bootstrap/typeahead/typeahead-container.component.ngfactory.ts 导入源文件
问题描述
你有什么建议,想法,我该如何解决以下错误?
这发生在我运行生产构建时。当我使用 -aot=false 运行生产构建时,更有趣的是它是成功的。
错误:错误:尝试从 node_modules 包中导入源文件:从 C:.../node_modules/ngx-bootstrap/typeahead/typeahead-container.component 导入 C:...search-scrollbar.directive.ts。 ngfactory.ts 在 TsCompilerAotCompilerTypeCheckHostAdapter.fileNameToModuleName (C:...\node_modules\@angular\compiler-cli\src\transformers\compiler_host.js:187:19) 在 AotCompiler._fileNameToModuleName (C:...\node_modules\@angular \compiler\bundles\compiler.umd.js:31099:24) 在 Object.importExpr$$1 [as importExpr] (C:...\node_modules\@angular\compiler\bundles\compiler.umd.js:31067:55 ) 在 singleProviderDef (C:...\node_modules\@angular\compiler\bundles\compiler.umd.js:20028:28) 在 providerDef (C:...\node_modules\@angular\compiler\bundles\compiler.umd .js:19962:9) 在 ViewBuilder._visitProviderOrDirective (C:...\node_modules\@angular\compiler\bundles\compiler.umd.js:28177:18) 在 ViewBuilder._visitDirective (C:...\node_modules\@angular\compiler\bundles\compiler.umd.js:28025:23)在 C:...\node_modules\@angular\compiler\bundles\compiler.umd.js:27926:32 在 Array.forEach (native) at ViewBuilder._visitElementOrTemplate (C:...\node_modules\@angular\compiler\ bundles\compiler.umd.js:27916:23) 在 ViewBuilder.visitElement (C:...\node_modules\@angular\compiler\bundles\compiler.umd.js:27820:23) 在 ElementAst.visit (C:. ..\node_modules\@angular\compiler\bundles\compiler.umd.js:925:24) 在访问 (C:...\node_modules\@angular\compiler\bundles\compiler.umd.js:1366:37)在 C:...\node_modules\@angular\compiler\bundles\compiler.umd.js:1368:42 在 Array.forEach (native) at templateVisitAll (C:...\node_modules\@angular\compiler\bundles\compiler.umd.js:1367:10)
解决方案
您正在导入源*.ts
文件而不是编译*.js
文件。确保你真的需要它。如果是 - 尝试在和/或文件中启用preserveSymlinks: true
选项。在我的情况下,它解决了这个错误。angular.json
tsconfig.json
推荐阅读
- python - 不理解 "or" & "==" 是 True 当它不是
- python-3.x - 发布一个 python 项目
- android - 如何在 RelativeLayout 设置 alpha TextView?
- apache-nifi - 用于将数据从 RDMBS 导入 HDFS 的 Apache NiFi - 与 SQOOP 的性能比较
- android - camera.setPreviewDisplay(holder); 录制视频时通过空指针异常
- jmeter - 在 JMeter 生成的 Report Dashboard 中包含自定义表格
- typescript - 多类型变量的通用约束
- c# - 检查是否设置了图像或在 xamarin.forms 中有图片
- python-3.6 - 如何从熊猫数据框中删除基线?
- c# - Hibernate 是否将“0”值更改为“NULL”?