加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 08:21:00 所属栏目:安全 来源:网络整理
导读:问题 ng serve Module build failed: Error: AotPlugin was detected but it was an instance of the wrong class. 完整错误报告日志 ERROR in ./src/main.ts Module build failed: Error: AotPlugin was detected but it was an instance of the wrong clas
问题

ng serve

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

完整错误报告日志

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:testingappnode_modules@ngtoolswebpacksrcloader.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

npm cache verify

仍然存在问题.

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

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

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

>删除@ ngtools / webpack

$npm remove –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"
          }
     }
     // ...
     }
     }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读