node.js - npm 更新后 angular-cli 构建错误

标签 node.js npm webpack angular-cli

切换到我的新电脑后,它具有较新的 Node 版本等。在尝试构建使用 Angular cli 设置的 Angular 项目时,出现以下错误:

开始:

10% building modules 2/2 modules 0 active(node:14472) DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead

稍后:

Error: Chunk.parents: Use ChunkGroup.getParents() instead

在 Google 中未找到此错误的任何结果

  • npm 版本:5.7.1
  • v8.9.0

包配置:

{
  "name": "...",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "build": "webpack",
    "build-css": "node build-sass.js",
    "test": "karma start ./karma.conf.js",
    "lint": "ng lint",
    "e2e": "protractor ./protractor.conf.js",
    "pree2e": "webdriver-manager update --standalone false --gecko false --quiet"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular-devkit/core": "0.3.1",
    "@angular/cli": "~1.7.0",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@cityofzion/neon-js": "3.2.1",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0",
    "@ngtools/webpack": "1.10.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "aes-js": "^3.1.0",
    "autoprefixer": "^7.2.3",
    "bootstrap": "^4.0.0",
    "circular-dependency-plugin": "^4.2.1",
    "codelyzer": "^4.0.1",
    "copy-webpack-plugin": "~4.4.2",
    "fast-sha256": "^1.1.0",
    "file-loader": "^1.1.5",
    "file-system": "^2.2.2",
    "html-webpack-plugin": "^2.29.0",
    "istanbul-instrumenter-loader": "^3.0.0",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "less-loader": "^4.0.5",
    "node-sass": "^4.7.2",
    "node-sass-tilde-importer": "^1.0.1",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.10",
    "postcss-url": "^7.1.2",
    "protractor": "~5.1.2",
    "raw-loader": "^0.5.1",
    "sass-loader": "^6.0.6",
    "style-loader": "^0.19.1",
    "stylus-loader": "^3.0.1",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3",
    "uglifyjs-webpack-plugin": "^1.1.8",
    "url-loader": "^0.6.2",
    "webpack": "~3.11.0",
    "webpack-dev-server": "~2.11.0"
  }
}

完整错误消息:

_>webpack
 10% building modules 2/2 modules 0 active(node:14472) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead                                                               76% basic chunk optimizationPATHnode_modules\webpack\lib\Chunk.js:438
                throw new Error("Chunk.parents: Use ChunkGroup.getParents() instead");
                ^

Error: Chunk.parents: Use ChunkGroup.getParents() instead
    at Chunk.get (PATHnode_modules\webpack\lib\Chunk.js:438:9)
    at CommonsChunkPlugin.getAffectedChunks (PATHPROJECT\webpack\lib\optimize\CommonsChunkPlugin.js:268:18)
    at targetChunks.forEach (PATHPROJECT\webpack\lib\optimize\CommonsChunkPlugin.js:110:34)
    at Array.forEach (<anonymous>)
    at compilation.plugin (PATHPROJECT\webpack\lib\optimize\CommonsChunkPlugin.js:105:18)
    at SyncBailHook.eval [as call] (eval at create (PATHnode_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:17:12), <anonymous>:7:16)
    at SyncBailHook.lazyCompileHook [as _call] (PATHnode_modules\webpack\node_modules\tapable\lib\Hook.js:35:21)
    at Compilation.seal (PATHnode_modules\webpack\lib\Compilation.js:874:30)
    at hooks.make.callAsync.err (PATHnode_modules\webpack\lib\Compiler.js:464:17)
    at _done (eval at create (PATHnode_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:9:1)
    at _err2 (eval at create (PATHnode_modules\webpack\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:44:22)
    at _addModuleChain (PATHnode_modules\webpack\lib\Compilation.js:749:12)
    at processModuleDependencies.err (PATHnode_modules\webpack\lib\Compilation.js:688:9)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)

最佳答案

我通过将我的global webpack版本从4.0.1降级3.11.0解决了这个问题

npm i -g webpack@3.11.0

关于node.js - npm 更新后 angular-cli 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49008681/

相关文章:

javascript - 是否可以为 Polymer 组件实现 Webpack HMR?

node.js - 范围内回调的最佳实践

node.js - 403 禁止在 Node.js 中使用 sendgrid 发送电子邮件

javascript - 如何在 Node.js 中正确使用 ssh2-sftp-client 库的 fastGet 方法?

node.js - 以 super 用户身份运行 npm,这不是一个好主意吗?

node.js - npm install 的问题(Angular)

javascript - Webpack CommonsChunkPlugin 未按预期工作

javascript - 在 NodeJS 的 ES6 回调中调用基类

docker - 'npm 错误!作为 docker 构建的一部分运行 npm install 时的自签名证书

javascript - 使用 webpack (Babel/ES6) 导入 moment-timzone 和 moment-range