. Advertisement .
. Advertisement .
The situation of updating a version to a newer version and an error occurs is quite familiar to programmers. This can happen in most browsers or applications. In this article, we will talk about Angular and specifically the “Could not find module ‘@angular-devkit/build-angular’” error. We will help you to find the best answer for this error . Let’s scroll down and get started on encountering the key right now!
What causes error?
In Angular 6.0, the developer released the
@angular-devkit/build-angular package that functions like a dependency. Therefore, in other more advanced versions of Angular, it will not be compatible. If you are using a version higher than Angular 6, it will show the error message
Could not find module '@angular-devkit/build-angular'
How to fix the error “Could not find module ‘@angular-devkit/build-angular'”?
The most common and recommended approach is to update to the new version. However, in this article we will introduce you to some other ways to handle it. Follow each method and choose the one that is convenient and right for you.
Solution 1: Remove and install new version
This is the easiest method to implement and the most widely used. First, you need to access the node_modules folder and manually delete the old versions that are pre-installed on the machine. Next run the command
npm cache clean --verify to clear the cache. And finally, run the command
npm install to fully install the Angular packages of the latest version.
Solution 2: Install new dependency package “@angular-devkit/build-angular”
In the Angular 6 version, the developer released a dependency package that is compatible with it, which is @angular-devkit/build-angular. Thus, the way to handle the above error was much simpler. By running one of the two commands below to install the package, the error should be fixed.
npm install --save-dev @angular-devkit/build-angular
yarn add @angular-devkit/build-angular --dev
Solution 3: Reinstall @angular/cli
If you have @angular/cli installed on your machine, you can also consider reinstalling it if the above two methods don’t work.
Similarly, first you need to remove the old version with the command “
npm uninstall -g @angular/cli“. Then run the command
npm cache clean --force to clear the cache. Now you can run
npm install -g @angular/cli@latest and
npm install to install the latest version for it. Finally run
ng build or
ng serve to launch the app.
Solution 4: Update version
If the above methods do not work, you can update the version again so that the error does not appear. Use the following command:
npm install npm update
Above is the best key to solve the error “Could not find module ‘@angular-devkit/build-angular’”. If you have any further questions, you can leave your comments in the Comments section. ITtutoria hopes you have a productive day with your subject. See you in the next session!