angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.72k stars 11.98k forks source link

getting TypeError: Cannot read property 'add' of undefined #21610

Closed w2819 closed 3 years ago

w2819 commented 3 years ago

🐞 Bug report

Command (mark with an x)

Description

update angular from v9 to v11,it report this error when run ` npm run build` or `npm run serve` it seems this file make this error: node_modules\@ngtools\webpack\src\ivy\plugin.js ``` if (webpack_version_1.isWebpackFiveOrHigher()) { console.log(compilation.fileDependencies) allProgramFiles.forEach((sourceFile) => compilation.fileDependencies.add(sourceFile.fileName)); } ``` ## πŸ”₯ Exception or Error

An unhandled exception occurred: Cannot read property 'add' of undefined
See "C:\Users\sc\AppData\Local\Temp\ng-oGEjnn\angular-errors.log" for further details.
or
An error occurred during the build:
TypeError: Cannot read property 'add' of undefined
    at D:\workspace\servever-platform-frontend\node_modules\@ngtools\webpack\src\ivy\plugin.js:171:86
    at Array.forEach ()
    at D:\workspace\servever-platform-frontend\node_modules\@ngtools\webpack\src\ivy\plugin.js:171:33
    at SyncHook.eval [as call] (eval at create (D:\workspace\servever-platform-frontend\node_modules\tapable\lib\HookCodeFactory.js:19:10), :15:1)
    at SyncHook.lazyCompileHook (D:\workspace\servever-platform-frontend\node_modules\tapable\lib\Hook.js:154:20)
    at Compiler.newCompilation (D:\workspace\servever-platform-frontend\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:630:30)
    at D:\workspace\servever-platform-frontend\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:667:29
    at AsyncSeriesHook.eval [as callAsync] (eval at create (D:\workspace\servever-platform-frontend\node_modules\tapable\lib\HookCodeFactory.js:33:10), :6:1)
    at AsyncSeriesHook.lazyCompileHook (D:\workspace\servever-platform-frontend\node_modules\tapable\lib\Hook.js:154:20)
    at Compiler.compile (D:\workspace\servever-platform-frontend\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:662:28)
    at D:\workspace\servever-platform-frontend\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:321:11
    at Compiler.readRecords (D:\workspace\servever-platform-frontend\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:529:11)
    at D:\workspace\servever-platform-frontend\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:318:10
    at AsyncSeriesHook.eval [as callAsync] (eval at create (D:\workspace\servever-platform-frontend\node_modules\tapable\lib\HookCodeFactory.js:33:10), :6:1)
    at AsyncSeriesHook.lazyCompileHook (D:\workspace\servever-platform-frontend\node_modules\tapable\lib\Hook.js:154:20)
    at D:\workspace\servever-platform-frontend\node_modules\@angular-devkit\build-angular\node_modules\webpack\lib\Compiler.js:315:19
An unhandled exception occurred: Cannot read property 'add' of undefined
See "C:\Users\sc\AppData\Local\Temp\ng-8lOiH4\angular-errors.log" for further details.
## 🌍 Your Environment

 "dependencies": {
    "@angular/animations": "^11.2.14",
    "@angular/cdk": "^11.2.13",
    "@angular/common": "^11.2.14",
    "@angular/core": "^11.2.14",
    "@angular/forms": "^11.2.14",
    "@angular/platform-browser": "^11.2.14",
    "@angular/platform-browser-dynamic": "^11.2.14",
    "@angular/router": "^11.2.14",
    "@ngrx/effects": "^11.1.1",
    "@ngrx/router-store": "^11.1.1",
    "@ngrx/store": "^11.1.1",
    "@nrwl/nx": "7.8.7",
    "aot-loader": "^1.0.1",
    "core-js": "^3.6.5",
    "date-fns": "^2.12.0",
    "echarts": "^4.1.0",
    "html-webpack-plugin": "^4.5.1",
    "html2canvas": "^1.0.0-rc.5",
    "jspdf": "^1.5.3",
    "moment": "^2.24.0",
    "ng-multiselect-dropdown": "^0.2.4",
    "ngrx-store-freeze": "0.2.4",
    "ngx-bootstrap": "^5.6.1",
    "ngx-drag-drop": "^2.0.0",
    "ngx-echarts": "^4.1.0",
    "ngx-img-cropper": "^11.0.0",
    "ngx-sortablejs": "^11.1.0",
    "qrcode": "^1.3.2",
    "rxjs": "^6.5.5",
    "rxjs-compat": "^6.5.5",
    "sortablejs": "^1.14.0",
    "tslib": "^2.0.0",
    "wangeditor": "^4.7.4",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-builders/custom-webpack": "^11.1.1",
    "@angular-devkit/build-angular": "^0.1102.14",
    "@angular/cli": "^11.2.14",
    "@angular/compiler": "^11.2.14",
    "@angular/compiler-cli": "^11.2.14",
    "@angular/language-service": "^11.2.14",
    "@angularclass/hmr": "^2.1.3",
    "@babel/plugin-syntax-dynamic-import": "^7.8.3",
    "@ngrx/store-devtools": "^11.1.1",
    "@nrwl/schematics": "8.12.11",
    "@nrwl/workspace": "^9.2.2",
    "@types/echarts": "^4.4.6",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "@types/sortablejs": "^1.10.7",
    "add-asset-html-webpack-plugin": "^3.1.3",
    "clean-webpack-plugin": "^3.0.0",
    "codelyzer": "^6.0.0",
    "hard-source-webpack-plugin": "^0.13.1",
    "jasmine-core": "~3.6.0",
    "jasmine-marbles": "0.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.4",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "prettier": "2.0.4",
    "protractor": "~7.0.0",
    "ts-node": "~8.8.2",
    "tslint": "~6.1.0",
    "typescript": "^4.1.6",
    "webpack": "^5.0.0",
    "webpack-bundle-analyzer": "^4.4.2",
    "webpack-cli": "^4.8.0"
  },
**Anything else relevant?**

image

alan-agius4 commented 3 years ago

Webpack 5 support in version 11 is experimental. Luckily, it has already been fixed in version 12. Please update to the most recent version to resolve the problem.

If the problem persists in your application after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. You can use ng new repro-app to create a new project where you reproduce the problem.

angular-automatic-lock-bot[bot] commented 2 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.