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

5

5

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"

Vehement answered 2/12, 2019 at 10:23 Comment(0)
D
5

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
Dissatisfy answered 2/12, 2019 at 10:27 Comment(1)
what happen in npm i ??Strike
Y
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.

Yentai answered 20/1, 2020 at 8:47 Comment(0)
S
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

Stonwin answered 2/12, 2019 at 10:31 Comment(0)
N
0

try this

npm install --save-dev @angular-devkit/build-angular
Nicolas answered 2/12, 2019 at 10:29 Comment(0)
M
0

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.

Mamey answered 20/1, 2020 at 8:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.