A Fix To Exception - Could Not Find Module “@angular-devkit/build-angular”

The exception: Could Not Find Module “@angular-devkit/build-angular” is very popular.  Google on the web, one can get tons of results of questions and answers. This article will give a fix to this Angular exception, and discuss a little bit about the reason and other possible solutions.

A: Process

Step 1

We need to run an Angular program, the computer has the current version of Angular installed,

Step 2

Change to app folder, build failed,

Step 3

We are suggested, the original Angular program was written by Version 6, then we switched back to Angular v 6.0.8.

Step 4

Re-run the program, we still get the error: Could Not Find Module “@angular-devkit/build-angular”.

Step 5

We run the fix - npm install --save-dev @angular-devkit/build-angular.

install @angular-devkit/build-angular

Step 6

After the fix, the Angular version became 8.3.26.

Step 7

Build --- successful!

Step 8

Run --- successful!

 

B: Possible Reason for the exception

We do not know exactly the reason for the exception, but one suggested,

It could be true although we did not do a thorough test, the computer we got the problem did involve TFS, Git process, while other computers when installing Git installation, the Angular program became weird. I believe, or assume, involving TFS or Git processes could be a reason affecting Angular working properly.

C: Other Solutions for this Exception

Our fix for the issue is to run MPM install locally to install the missing components, "@angular-devkit/build-angular". Another approach is to check Angular global installation, if "@angular-devkit/build-angular" exists, and then check the package.json file, see if the component is in the “DevDependencies” and “dependencies” blocks; if not, add 

"@angular-devkit/build-angular":"^0.13.9", into the “devDependencies” block.

You may check the Angular packages installation globally by,

npm list -g depth=1

This solution could be found in this article.

Summary

This article is a fix of a popular Angular exception. 

References

We can see tons of articles discussion online about this exception, we quote several here,