我在Angular CLI v1.6.3上运行Angular 5应用程序。我需要使用一个名为ng2-img-map
的库,因为它是其中一个问题的唯一可行解决方案。但是,当我运行ng build --prod
时,它会抛出。
ERROR in : Unexpected value 'ImgMapComponent in C:/Users/.../node_modules/ng2-img-map/ng2-img-map.d.ts' declared by the module 'AppModule in C:/Users/.../src/app/app.module.ts'. Please add a @Pipe/@Directive/@Component annotation.
当我只运行ng build
时,它没有问题。
我注意到这种情况发生在其他ng2-
库中,这些库在一年左右的时间内没有更新过。我只是使用其他东西,但是我没有选择/时间。
我有什么办法可以修复/绕过这个并在--prod
模式下使用库吗?
答案 0 :(得分:0)
尝试修改你的tsconfig.json,添加一个声明:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
],
"declaration": [
"pathToYourFile.d.ts"
]
}
}