build - Angular 5 错误 :Trying to import a source file from a node_modules/node_modules/ngx-bootstrap/typeahead/typeahead-container. component.ngfactory.ts

标签 build compiler-errors angular5 ngx-bootstrap aot

你有什么建议,想法,我该如何解决以下错误?

这发生在我运行生产构建时。
当我使用 -aot=false 运行生产构建时,更有趣的是它是成功的。

错误:错误:尝试从 node_modules 包中导入源文件:从 C 中导入 C:...search-scrollbar.directive.ts:
.../node_modules/ngx-bootstrap/typeahead/typeahead-container.component.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 )
在 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 )
在 templateVisitAll (C:...\node_modules\@angular\compiler\bundles\compiler.umd.js:1367:10)

最佳答案

您正在导入源 *.ts文件而不是编译 *.js文件。确保你真的需要它。如果是,请尝试启用 preserveSymlinks: true angular.json 中的选项和/或 tsconfig.json文件。在我的情况下,它解决了这个错误。

关于build - Angular 5 错误 :Trying to import a source file from a node_modules/node_modules/ngx-bootstrap/typeahead/typeahead-container. component.ngfactory.ts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50408354/

相关文章:

gradle - 将 ant signJar 任务转换为 gradle

compiler-errors - 有些人在gcc中定义了编译成功,但是g++失败了

angular - 如何将多个值传递给 angular 5 observable?

android - ionic cordova使用gradle构建android错误

python - Python 3.6 的 boost 和 dlib 安装期间出错

build - 发布构建与夜间构建

具有可变大小的 C++ 全局队列数组

visual-studio - Typescript 2.0 tsc.exe 代码 1 错误(升级后)

css - Angular 5 和 :host pseudo class

Angular 5 管道和动态语言环境