2022年1月13日更新解决办法
前情提要
拿到同事给的项目,手起刀落,直接npm install,结果报错了。
npm ERR! code E404
npm ERR! 404 Not Found - GET <公司镜像地址>/<包名> - not_found
npm ERR! 404
npm ERR! 404 <包名> is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of <项目名>
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\****\npm-cache\_logs\2021-04-30T02_51_16_721Z-debug.log
过程
万事开头难,没想到这个有这么难,在公司咨询了好多人,无人提出一个解决办法。最后只能采取离线安装的方式展示解决了。根源问题等笔者找到了后,再更新。
办法
离线安装方式:
- 在仓库内找到该包,下载tgz,放在项目同层级目录
- 在项目内
npm install ../<.tgz>,即可安装 - 成功后可以看到
package.json内对这个包的依赖也变成了文件相对路径 - 最后再执行
npm install安装其它的依赖包
后续
2022年1月13日,同事自己上传的npm包下载时也是提示404报错,他那边找到了相关同事给出了方法去下载。
- 执行
npm logout - 执行
npm install即可下载了