搭建cnpm遇到的那些坑儿

搭建cnpm私有库之后,针对发布私有包和install私有包时可能遇到的坑。

npm login   // OR cnpm login
Username: xxxx
Password:
Email: (this IS public) xxx@xxx.com
Logged in as xxx on http://xxxxxxx/.

登录成功。但是发布私有包却报错,npm publish:

npm ERR! publish Failed PUT 401
npm ERR! code E401
npm ERR! 404 unauthorized Login first: <package>
npm ERR! 404
npm ERR! 404  '<package>' 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
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!     /Users/eugene/.npm/_logs/2018-05-30T08_12_38_183Z-debug.log

此处发包碰到此问题的原因可能会出现以下几点:

  1. npm 源设置的不对,需要重新npm config set registry https://xxxxxxx
  2. npm 源正确设置,登录成功,但是发包一直401。这时如果找不到问题所在,切换至cnpm会有意想不到收获。设置cnpm源,并使用cnpm login,然后cnpm publish。

对于cnpm install 会碰到的问题:

cnpm install <package> 的时候一直retry,最后报ResponseError: socket hang up (req "error")。

解决方案:在config/index.js里有个配置,我看到的所有文章都没有提到。

// registry url name
registryHost: 'r.cnpmjs.org', // 修改成你自己服务器host。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容