使用jenkins进行npm i时,出现
在jenkins机器上npm install也出现这个问题,看到网上说删除node_modules、package-lock.json之后,使用npm cache clean --force 清除缓存之后,再npm i。不过这个方法得多次重复才可以。
npm install执行过程:
- 执行npm install
- npm向registry请求查询对应的包
- 下载压缩包,放在~/.npm中
- 解压压缩包到当前项目的node_modules中
所以本地是存了两份的,在已经存在的情况下,执行npm install,如果node_modules中没有,则会向registry中请求,而不是用本地压缩包。 我们在npm install的过程中,发生这个错误是因为~/.npm/_cacache中的某些json文件发生了错误。