npm下载包报错解决方案


npm下载包的时候突然报错

报错1:
npm install报错npm WARN tar ENOENT: no such file or directory, open ‘...\node_modules\.staging\...’

有看到一些文章说删除package.json,然后重新npm install安装就可以解决,亲测这个方法是不行的,依然还是会报相同的错误。

正确的解决办法:删除文件 package-lock.json,重现执行npm install,然后再启动就可以了。下次其他包的时候也不会报错了。

报错2:

npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected]
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget 
npm ERR! notarget It was specified as a dependency of 'project-name'
npm ERR! notarget 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/dragon/.npm/_logs/2018-12-19T11_45_03_469Z-debug.log


解决方法
从错误信息:No matching version found for [email protected]能够知道,是因为没有找到这个包的3.3.6版本。
首先去 https://www.npmjs.com/ 网站搜索这个包,看看是否发布了这个版本:

如果是私有代理proxy仓库,可以清理一下私有仓库的缓存(invalidate cache)

你可能感兴趣的:(运维笔记,npm,前端,node.js)