npm install 报错解决

npm安装cnpm时报各种关于package.json的解析错误,经过多次使用'npm cache clean --force'命令清除缓存再安装后最终报如下错误:

npm ERR! code EINTEGRITY
npm ERR! sha1-wgdX/nLucSeOoP89h+XCyjDZ7fg= integrity checksum failed when using sha1: wanted sha1-wgdX/nLucSeOoP89h+XCyjDZ7fg= but got sha1-Qfc3yuL3VpD7S/vTCTybJry8+uE=. (24612 bytes)

查了一翻资料应该是npm版本过低问题,于是执行'npm install -g npm'命令升级版本,然后在执行安装'npm install -g cnpm --registry=https://registry.npm.taobao.org',报错如下:

npm ERR! code EINTEGRITY
npm ERR! Verification failed while extracting node-gyp@^3.6.2:
npm ERR! sha1-m/vlRWIoYoSDjnUOrAUpWFP6HGA= integrity checksum failed when using sha1: wanted sha1-m/vlRWIoYoSDjnUOrAUpWFP6HGA= but got sha512-qCYQ3agDYou0MZbXfVkt6zvzbXQxJuocoAs4MTbef1+p19dMXfu8Ep/JHMnMHs3JlxDYr9XvALnbh68pHth9UA== sha1-Q+d4hbpuN1jlIc+qNkie7y+jLw0=. (40579 bytes)

然后再执行'npm cache clean --force'清缓存再安装,再清缓存再安装.....反复几次后,终于安装成功。胜利的提示如下:

C:\Windows\System32>npm install -g cnpm --registry=https://registry.npm.taobao.org
C:\Users\lxz\AppData\Roaming\npm\cnpm -> C:\Users\lxz\AppData\Roaming\npm\node_modules\cnpm\bin\cnpm
+ [email protected]
added 778 packages from 772 contributors in 161.031s
至于为什么要反复清缓存再安装呢?我也没清楚,反正发现每次清缓存再安装报的错误都会不一样,所以反复尝试了几次就ok了

你可能感兴趣的:(前端)