首页 > 解决方案 > 从 Bintray 存储库中解析 NPM 包

问题描述

我在 Bintray 上创建了一个私有 NPM 存储库。我~/.npmrc通过运行添加了必要的身份验证凭据

curl -u BINTRAY_USER:BINTRAY_API_TOKEN 
https://api.bintray.com/npm/my-company/npm/auth/scope/my-company > ~/.npmrc

我已经成功部署了一个名为foo这个 NPM 存储库的包的 1.0.0 版本,并将它作为依赖项添加到另一个项目的 `package.json

"dependencies": {
  "@my-company/foo": "1.0.0"
}

但是当我npm install在这个项目中运行时,我得到一个 404 错误

npm ERR! code E401
npm ERR! 401 Unauthorized: @my-company/foo@1.0.0

当我登录到 Bintray 应用程序时,我可以看到 1.0.0 版本foo已部署,那么为什么解析失败?

标签: npmbintray

解决方案


401 Unauthorized error usually occurs when wrong user id or credentials use. it could be cache issue anyhow you can try run npm cache clean first and then re-run npm install or you can try with npm install -verbose which will show more information.

For the reference, the following .npmrc file works:

@my-company:registry=api.bintray.com/npm/my-company/npm
//api.bintray.com/npm/my-company/npm/:_authToken=BINTRAY_API_TOKEN 
//api.bintray.com/npm/my-companyl/npm/:username=my.username 
//api.bintray.com/npm/my-company/npm/:email=my@email.com 
//api.bintray.com/npm/my-company/npm/:always-auth=true

推荐阅读