angular-cli build errors after npm update

2019-07-31 11:09发布

问题:

After switching to my new pc, which has newer node versiones etc. I get the following error when trying to build my angular project set up with angular cli:

Start:

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

Later:

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

Didn't find any results for this error in google

  • npm Verions: 5.7.1
  • v8.9.0

packageconfig:

{
  "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"
  }
}

Full error message:

_>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)

回答1:

I solved this problem by downgrading my global webpack version from 4.0.1 to 3.11.0

npm i -g webpack@3.11.0