Could not find module '@angular-devkit/build-angular'

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
2 min

banner

# Could not find module '@angular-devkit/build-angular'

To solve the error "Could not find module '@angular-devkit/build-angular'", make sure to install the package by opening your terminal in your project's root directory and running the following command: npm i -D @angular-devkit/build-angular and restart your IDE and development server.

Open your terminal in your project's root directory (where your package.json file is located) and run the following command:

shell
# ๐Ÿ‘‡๏ธ with NPM npm install --save-dev @angular-devkit/build-angular # ๐Ÿ‘‡๏ธ or with YARN yarn add @angular-devkit/build-angular --dev

install angular devkit build angular module

This will add the @angular-devkit/build-angular package to the development dependencies of your project.

If the error is not resolved, try restarting your IDE and your development server.

If you still get the error, try to update the versions of your NPM packages by running the following command:

shell
npm update

issue npm update command

# Delete your node_modules and reinstall your dependencies

If the error is not resolved, try to delete your node_modules and package-lock.json (not package.json) files, re-run npm install and restart your IDE.

shell
# ๐Ÿ‘‡๏ธ (macOS/Linux) delete node_modules and package-lock.json rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # ๐Ÿ‘‡๏ธ (Windows) delete node_modules and package-lock.json rd /s /q "node_modules" del package-lock.json del -f yarn.lock # ๐Ÿ‘‡๏ธ clean your npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install npm install --save-dev @angular-devkit/build-angular
Make sure to restart your IDE and dev server if the error persists. VSCode often glitches and a reboot solves things sometimes.

If you get any errors with the installation of the package, try running the command with the --force flag.

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

# Verify the package is installed

If you still get the error, open your package.json file and make sure it contains the @angular-devkit/build-angular package in the devDependencies object.

package.json
{ // ... rest "devDependencies": { "@angular-devkit/build-angular": "^13.3.0", } }

You can try to manually add the line and re-run npm install.

shell
npm install

Or install the latest version of the package:

shell
npm install --save-dev @angular-devkit/build-angular@latest # ๐Ÿ‘‡๏ธ with YARN yarn add @angular-devkit/build-angular@latest --dev

The @angular-devkit/build-angular module should NOT be globally installed or be in your project's dependencies, it should be in the devDependencies object in your package.json file.

# Reinstall the Angular CLI

Run the following commands to reinstall the @angular/cli package if the error persists.

shell
npm uninstall -g @angular/cli npm cache clean --force npm install -g @angular/cli@latest npm install ng build ng serve

If the error is not resolved, try restarting your IDE and your development server.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev