【NodeJS】Angular Compiler Error (seems to be the wrong instance)



    NodeJS前端编译报错

    ERROR in ./src/main.ts Module build failed: Error: Angular Compiler was detected but it was an instance of the wrong class. This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies. at Object.ngcLoader (/opt/XXX/node_modules/@ngtools/webpack/src/loader.js:458:19) ERROR in ./src/polyfills.ts Module build failed: Error: Angular Compiler was detected but it was an instance of the wrong class. This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies. at Object.ngcLoader (/opt/XXX/node_modules/@ngtools/webpack/src/loader.js:458:19) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! frontend@0.0.0 prod: `ng build --prod --aot` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the frontend@0.0.0 prod script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2018-04-06T06_25_00_960Z-debug.log



    解决方案:

    1. 删除package-lock.json和node_modules文件夹
    2. 重新跑npm install

    圆满解决。这只是其中一种情况,根据错误提示里的查看@ngtools/webpack是否有多个版本也是一个常识。






    本博客所有文章如无特别注明均为原创。
    复制或转载请以超链接形式注明转自枫芸志,原文地址《【NodeJS】Angular Compiler Error (seems to be the wrong instance)
    分享:

还没有人抢沙发呢~

无觅相关文章插件,快速提升流量