npm安装cnpm时候报错code EINTEGRITY

时间:2022-10-31 03:51:36

npm安装cnpm时候报错code EINTEGRITY
错误展示

PS C:\Users\by\Desktop\element_ui_demo> npm install --g  npm
npm ERR! code EINTEGRITY
npm
ERR!
sha512-DowXzQwtSWDtbAjuWecuEiismR0VdNEYaL3VxNTYTdW6AGkYxfGk9LUZ/rt6etEyiH4IEk95HkJeGfXE5Rz9xQ==
integrity checksum failed when using sha512: wanted
sha512-DowXzQwtSWDtbAjuWecuEiismR0VdNEYaL3VxNTYTdW6AGkYxfGk9LUZ/rt6etEyiH4IEk95HkJeGfXE5Rz9xQ==
but got
sha512-tHlXGeHDDxcwcfwJc/dRDLcLCtuq5y9ATPgiG9tkyLom4u9Yqc+nRbk0JI7c2biglh8jwsUIseBIivimVFmZQg==.
(5156776 bytes)

原因是npm版本过低解决办法

1.如果有package-lock.json文件,就删掉

2.管理员权限进入cmd

3.执行npm cache clean --force

4.之后再npm install -g npm

5.npm -v查看版本