角度:发生未处理的异常:找不到模块'webpack'?

Posted

技术标签:

【中文标题】角度:发生未处理的异常:找不到模块\'webpack\'?【英文标题】:angular: An unhandled exception occurred: Cannot find module 'webpack'?角度:发生未处理的异常:找不到模块'webpack'? 【发布时间】:2021-03-09 23:22:27 【问题描述】:

我正在做一个项目,在我升级了 angular 版本后,我开始收到这个错误,谁能帮我确定这个错误? 我已尝试删除 node_modules、package-lock.json 并重新安装 angular 和 cli 但无法解决此问题。 npm start 给了我这个错误 发生未处理的异常:找不到模块“webpack” 需要堆栈:

C:\Users\HP\Desktop\New 文件夹\gitlab repos\lms-dashboard\node_modules@angular-devkit\build-webpack\src\webpack\index.js C:\Users\HP\Desktop\New 文件夹\gitlab repos\lms-dashboard\node_modules@angular-devkit\build-webpack\src\index.js C:\Users\HP\Desktop\New folder\gitlab repos\lms-dashboard\node_modules@angular-devkit\build-angular\src\dev-server\index.js C:\Users\HP\Desktop\New 文件夹\gitlab repos\lms-dashboard\node_modules@angular-devkit\architect\node\node-modules-architect-host.js C:\Users\HP\Desktop\New 文件夹\gitlab repos\lms-dashboard\node_modules@angular-devkit\architect\node\index.js C:\Users\HP\Desktop\New 文件夹\gitlab repos\lms-dashboard\node_modules@angular\cli\models\architect-command.js C:\Users\HP\Desktop\New folder\gitlab repos\lms-dashboard\node_modules@angular\cli\commands\serve-impl.js C:\Users\HP\Desktop\New 文件夹\gitlab repos\lms-dashboard\node_modules@angular-devkit\schematics\tools\export-ref.js C:\Users\HP\Desktop\New 文件夹\gitlab repos\lms-dashboard\node_modules@angular-devkit\schematics\tools\index.js C:\Users\HP\Desktop\New folder\gitlab repos\lms-dashboard\node_modules@angular\cli\utilities\json-schema.js C:\Users\HP\Desktop\New 文件夹\gitlab repos\lms-dashboard\node_modules@angular\cli\models\command-runner.js C:\Users\HP\Desktop\New 文件夹\gitlab repos\lms-dashboard\node_modules@angular\cli\lib\cli\index.js C:\Users\HP\Desktop\New 文件夹\gitlab repos\lms-dashboard\node_modules@angular\cli\lib\init.js C:\Users\HP\Desktop\New 文件夹\gitlab repos\lms-dashboard\node_modules@angular\cli\bin\ng 有关详细信息,请参阅“C:\Users\HP\AppData\Local\Temp\ng-9d5ZFx\angular-errors.log”。 npm 错误!代码生命周期 npm 错误!系统调用生成 npm 错误!文件 C:\Windows\system32\cmd.exe npm 错误! errno ENOENT npm 错误! scssdestmoney@1.0.0 开始:ng serve --port 4201 npm 错误!生成 ENOENT npm 错误! npm 错误!在 scssdestmoney@1.0.0 启动脚本中失败。 npm 错误!这可能不是 npm 的问题。上面可能还有额外的日志输出。

npm 错误!可以在以下位置找到此运行的完整日志: npm 错误! C:\Users\HP\AppData\Roaming\npm-cache_logs\2020-11-27T06_17_52_442Z-debug.log package.json


  "name": "scssdestmoney",
  "version": "1.0.0",
  "license": "MIT",
  "scripts": 
    "build-prod": "bash ./scripts/ng.sh build --prod --aot --env=prod",
    "ng": "ng",
    "start": "ng serve --port 4201",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  ,
  "private": true,
  "dependencies": 
    "@angular/animations": "^4.4.7",
    "@angular/common": "^4.4.7",
    "@angular/compiler": "^4.4.7",
    "@angular/core": "^4.4.7",
    "@angular/forms": "^4.4.7",
    "@angular/http": "^4.4.7",
    "@angular/material": "^11.0.1",
    "@angular/platform-browser": "^4.4.7",
    "@angular/platform-browser-dynamic": "^4.4.7",
    "@angular/router": "^4.4.7",
    "@types/selenium-webdriver": "2.53.33",
    "@zoomus/websdk": "^1.8.0",
    "angular-material": "^1.2.1",
    "angular2-jwt": "^0.2.2",
    "animate.css": "3.5.2",
    "async": "^3.2.0",
    "binding": "^3.0.3",
    "chart.js": "^2.7.3",
    "core-js": "^2.5.7",
    "dateformat": "^3.0.3",
    "font-awesome": "4.7.0",
    "jquery": "3.1.1",
    "ng-socket-io": "^0.2.4",
    "ng2-charts": "^1.6.0",
    "node-sass": "^4.13.0",
    "primeicons": "^1.0.0",
    "primeng": "^4.3.0",
    "protractor": "^5.4.2",
    "rxjs": "^5.5.12",
    "websdk": "^3.0.0",
    "wowjs": "1.1.3",
    "xlsx": "^0.14.2",
    "zone.js": "^0.8.29"
  ,
  "devDependencies": 
    "@angular-devkit/build-angular": "~0.1100.2",
    "@angular/cli": "^11.0.2",
    "@angular/compiler-cli": "^4.4.7",
    "@angular/language-service": "^4.4.7",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^6.14.5",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.4.3",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "^2.3.4"
  

【问题讨论】:

你能发布你的 package.json 吗? 更新了上面的package.json 【参考方案1】:

尝试使用 npm install webpack 安装它

【讨论】:

以上是关于角度:发生未处理的异常:找不到模块'webpack'?的主要内容,如果未能解决你的问题,请参考以下文章

离子应用程序:发生未处理的异常:找不到模块“@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/uti

发生未处理的异常:找不到模块'@angular-devkit/build-angular/package.json'

安装角度编译器的问题

找不到模块角度

找不到模块角度/动画

找不到模块'@schemics/angular/utility/project'