错误:AotPlugin被检测到,但它是一个错误类的实例
问题
服务
模块构build失败:错误:AotPlugin被检测到,但是它是一个错误类的实例。
完整的错误报告日志
ERROR in ./src/main.ts Module build failed: Error: AotPlugin 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 (D:\testingapp\node_modules\@ngtools\webpack\src\loader.js:358:19) @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
npm ls @ ngtools / webpack
testingapp@0.0.0 D:\testingapp +-- @angular/cli@1.2.6 | `-- @ngtools/webpack@1.5.5 `-- angular-cli@1.0.0-beta.28.3 `-- @ngtools/webpack@1.5.1
npmcachingvalidation
仍然存在问题。
- 任何build议是最受欢迎的。
运行ng eject
并尝试运行我的业力testing后,出现这个问题。
即使我不认为这是一个最佳的解决scheme,我通过以下方式解决了这个问题:
-
删除
@ngtools/webpack
$ npm删除–save @ ngtools / webpack
-
在我的webpack.config.js中需要
@ngtools/webpack
,它是@angular/cli
的子依赖项// webpack.config.js // // Other require statements const { AotPlugin } = require('./node_modules/@angular/cli/node_modules/@ngtools/webpack');
/ * *更改加载器/ *
module.exports = { // ... "module": { "rules": { // ... { "test": /\.ts$/, /* REMOVE: "loader": "@ngtools/webpack", */ "loader": "./node_modules/@angular/cli/node_modules/@ngtools/webpack" } } // ... } }
我有同样的问题,现在修好了。
首先使用ng -v
检查所有依赖项的版本,并检查其他正在运行的应用程序的相同版本,您肯定会得到一些版本差异,所以请尝试降级/升级到正常工作。
在我的情况下,我已经安装了节点8导致同样的问题。 通过简单降级通过nvm解决了我的问题。
如何安装nvm链接一个
如何安装nvm连接两个
你可以按照任何一个链接安装nvm
我有同样的错误。 只是更新angular度cli,并做了npm更新,一切都很好。
我开始怀疑更新angular度cli是持续的相当于“你试过把它打开和closures吗? ;)
我最近有一个类似的问题,不同的版本@ angular / cli @ 1.4.9和@ ngtools / webpack @ 1.7.4
├─┬ @angular/cli@1.4.9 │ └── @ngtools/webpack@1.7.4 └── @ngtools/webpack@1.7.4
下面的代码可以在https://github.com/angular/angular-cli/wiki/stories-1.0-update
npm uninstall -g angular-cli npm uninstall --save-dev angular-cli npm uninstall -g @angular/cli npm uninstall --save-dev @angular/cli rm -rf node_modules dist npm cache clean npm install -g @angular/cli@latest npm install --save-dev @angular/cli@latest npm install