An unhandled exception occurred: Could not find module “@angular-devkit/build-angular”

好久不见. 提交于 2020-07-03 04:23:08

问题


When running the terminal commands ng server or ng serve I'm getting this issue:

An unhandled exception occurred: Could not find module "@angular-devkit/build-angular"


回答1:


Check in your package.json to see if you have this package in your devDependencies section or not

"devDependencies": {
    "@angular-devkit/build-angular": "~0.803.18"
}

If exist try to

delete package-lock.json or yarn-lock.json

run

npm cache clean --force

then run

npm i



回答2:


This error (Unhandled exception for a module) occurs when node_modules folder does not exist inside the project, or when the folder exists, but does not contain all the dependencies downloaded.

$ npm install command will download all the dependencies into the node_modules folder of the proejct.

npm install is automatically triggered in the background by the 'ng new', at the time of creation of the angular project.

The other angular commands like 'ng build' or 'ng serve' commands assume that 'ng new' had completed successfully.

If, for some reason, the npm install failed at the time of creation, or if the node_modules folder got deleted after the project was created, then the other angular commands (ng serve, ng build, ...) will generate this 'Unhandled Exception'.

Manually executing the npm install command inside the project will download the dependencies and fix the issue.




回答3:


try this

npm install --save-dev @angular-devkit/build-angular



回答4:


Install @angular-devkit/build-angular as dev dependency.

npm install --save-dev @angular-devkit/build-angular

or,

yarn add @angular-devkit/build-angular --dev




回答5:


Make sure "@angular-devkit/build-angular": "~0.10.0" is available in devDependencies of package.json before running npm install in your angular root directory.



来源:https://stackoverflow.com/questions/59136899/an-unhandled-exception-occurred-could-not-find-module-angular-devkit-build-an

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!