npm ERR integrity checksum failed when using sha wanted xxxx but got yyyy

Original link: https://blog.kelu.org/tech/2023/05/23/nodejs-npm-checksum.html

A front-end assembly line that hasn’t been touched for a long time, I found that I couldn’t make it up. It can’t be edited locally. I asked the manufacturer, but the manufacturer was at a loss and did not give any good advice:

 npm ERR! Verification failed while extracting @babel/[email protected]. 

image-20230525pm81829074

For this reason, I even specially installed the same version of node and npm as the manufacturer, but it still doesn’t work, which is annoying.

In the spirit of asking gpt first in case of indecision, after asking it, the solutions he gave were useless.

image-20230525 PM 81657915

I tried to run it, but as the front end of a half-bucket of water, it is really big, and it is useless. It seems that we still have to rely on Google to read it slowly.

I know more about php-related projects, and composer also uses lock files as a snapshot slice for version management.

In fact, it is a good way to delete the lock file and install again, and it will definitely succeed. After success, I compared the lock file, and there are many changes with the previous one. As a newcomer, I really don’t have the courage to delete the lock file of this front-end file and install it again, for fear that other errors will make it more difficult to find the problem.

So I used a conservative method to directly change the content in the lock file, first search for the value of the first sha1, and then replace it with the value of the second sha1:

image-20230525pm82942262

I can finally compose it~~

References

This article is transferred from: https://blog.kelu.org/tech/2023/05/23/nodejs-npm-checksum.html
This site is only for collection, and the copyright belongs to the original author.