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"

0

5 Answers

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 
1

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

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

or,

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

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.

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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy