When running the terminal mands ng server or ng serve I'm getting this issue:
An unhandled exception occurred: Could not find module "@angular-devkit/build-angular"
When running the terminal mands ng server or ng serve I'm getting this issue:
An unhandled exception occurred: Could not find module "@angular-devkit/build-angular"
Share Improve this question edited Dec 13, 2019 at 7:00 Tony 20.1k7 gold badges41 silver badges62 bronze badges asked Dec 2, 2019 at 10:23 Ganesh PabaleGanesh Pabale 551 gold badge1 silver badge8 bronze badges 05 Answers
Reset to default 5Check 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
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 mand 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 mands like 'ng build' or 'ng serve' mands assume that 'ng new' had pleted 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 mands (ng serve, ng build, ...) will generate this 'Unhandled Exception'.
Manually executing the npm install mand inside the project will download the dependencies and fix the issue.
Install @angular-devkit/build-angular as dev dependency.
npm install --save-dev @angular-devkit/build-angular
or,
yarn add @angular-devkit/build-angular --dev
try this
npm install --save-dev @angular-devkit/build-angular
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.