ng build--当我尝试在应用程序模块中导入javascript文件时,prod失败

ng build--当我尝试在应用程序模块中导入javascript文件时,prod失败,javascript,angular,angular6,aot,ng-build,Javascript,Angular,Angular6,Aot,Ng Build,我必须在我的应用程序模块中导入一个javascript文件 从“./node_modules/blahblah/OtherComponent.js”导入{OtherComponent} 注意,这个OtherComponent已经是一个javascript文件了 然后在@NgModule中,我将这个组件添加到我的声明中 当我运行“ng build--prod”时,它会给我错误信息: 错误模块声明的意外值“OtherComponent” “应用模块” 请添加@Pipe/@Directive/@组件注

我必须在我的应用程序模块中导入一个javascript文件

从“./node_modules/blahblah/OtherComponent.js”导入{OtherComponent}

注意,这个OtherComponent已经是一个javascript文件了

然后在@NgModule中,我将这个组件添加到我的声明中

当我运行“ng build--prod”时,它会给我错误信息:

错误模块声明的意外值“OtherComponent” “应用模块”

请添加@Pipe/@Directive/@组件注释


有办法解决这个问题吗?当我无法访问OtherComponent的ts文件时。

您不应该像这样导入JS文件

在angular-cli.json文件中

“脚本”:[ “/node_modules/blahblah/OtherComponent.js”]


然后重新启动项目。这应该可以完成任务。

好的。但是,这个OtherComponent必须在appmodule中声明,以便我可以在整个应用程序中使用它。可能吗?好的。为此,在typings.d.ts declare var OtherComponent:any中添加此项;从“otherComponent”将其作为Import*作为otherComponent导入到您的文件中;还是不走运。当我从“otherComponent”将*作为otherComponent导入时,无法识别“otherComponent”