angularjs – 错误:检测到AotPlugin但它是错误类的实例

前端之家收集整理的这篇文章主要介绍了angularjs – 错误:检测到AotPlugin但它是错误类的实例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
问题

ng serve

Module build Failed: Error: AotPlugin was detected but it was an instance of the wrong class.

完整错误报告日志

  1. ERROR in ./src/main.ts
  2. Module build Failed: Error: AotPlugin was detected but it was an instance of the wrong class.
  3. 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.
  4. at Object.ngcLoader
  5. (D:\testingapp\node_modules\@ngtools\webpack\src\loader.js:358:19)
  6. @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

npm ls @ngtools/webpack

  1. testingapp@0.0.0 D:\testingapp
  2. +-- @angular/cli@1.2.6
  3. | `-- @ngtools/webpack@1.5.5
  4. `-- angular-cli@1.0.0-beta.28.3
  5. `-- @ngtools/webpack@1.5.1

npm cache verify

仍然存在问题.

>任何建议都是最受欢迎的.

运行ng弹出并尝试运行我的业力测试后,这个问题出现了.

即使我不认为这是一个最佳解决方案,我通过以下方式解决了这个问题:

>删除@ ngtools / webpack

$npm remove –save @ ngtools / webpack
>在我的webpack.config.js中要求@ ngtools / webpack是@ angular / cli的子依赖项

  1. // webpack.config.js
  2. //
  3. // Other require statements
  4. const { AotPlugin } =
  5. require('./node_modules/@angular/cli/node_modules/@ngtools/webpack');

/ *
*更改装载机
/ *

  1. module.exports = {
  2. // ...
  3.  
  4. "module": {
  5. "rules": {
  6. // ...
  7. {
  8. "test": /\.ts$/,/* REMOVE: "loader": "@ngtools/webpack",*/
  9. "loader":
  10. "./node_modules/@angular/cli/node_modules/@ngtools/webpack"
  11. }
  12. }
  13. // ...
  14. }
  15. }

猜你在找的Angularjs相关文章