升级Angular后ng serve出错Cannot find module @angular-devkit/build-angular/package.json

Webstom运行Angular项目出错:
升级了Angular版本后,原来的项目版本低了,与新版本不匹配,所以运行了出现如下错误

An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Require stack:
- C:\Users\hyh\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- C:\Users\hyh\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\index.js
- C:\Users\hyh\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js
- C:\Users\hyh\AppData\Roaming\npm\node_modules\@angular\cli\commands\serve-impl.js
- C:\Users\hyh\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\tools\export-ref.js
- C:\Users\hyh\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\tools\index.js
- C:\Users\hyh\AppData\Roaming\npm\node_modules\@angular\cli\utilities\json-schema.js
- C:\Users\hyh\AppData\Roaming\npm\node_modules\@angular\cli\models\command-runner.js
- C:\Users\hyh\AppData\Roaming\npm\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\hyh\AppData\Roaming\npm\node_modules\@angular\cli\lib\init.js
- C:\Users\hyh\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
See "C:\Users\hyh\AppData\Local\Temp\ng-OA8Bc8\angular-errors.log" for further details.

解决办法:
1.要安装package.json中提到的包:

npm install

2.删除无关的包

npm prune

然后再输入ng serve运行就没问题了
升级Angular后ng serve出错Cannot find module @angular-devkit/build-angular/package.json_第1张图片
升级Angular后ng serve出错Cannot find module @angular-devkit/build-angular/package.json_第2张图片

你可能感兴趣的:(纠错,软件配置)