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


Borislav Hadzhiev

Last updated: Mar 28, 2022


Photo from Unsplash

Fix - 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:

npm install --save-dev @angular-devkit/build-angular
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:

npm update

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.

# 👇️ delete node_modules and package-lock.json rm -rf node_modules rm -f package-lock.json # 👇️ clean npm cache npm cache clean --force npm install
Make sure to restart your IDE and dev server if the error still 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.

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

If you're still getting the "Cannot find module '@angular-devkit/build-angular'" error, open your package.json file and make sure it contains the @angular-devkit/build-angular package in the devDependencies object.

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

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

npm install

Or install the latest version of the package:

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

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.

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.