npm - 从 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
已部署,那么为什么解析失败?
解决方案
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
推荐阅读
- php - 多维关联数组,用于登录的 session() 和 isset(),我做错了什么?
- node-red - 为什么我的 CSS 文件没有在 Node-RED 上加载?
- node.js - 在 MERN Web 应用程序中实现基于角色的身份验证
- javascript - TypeError:undefined 不是构造函数
- matlab - 重塑数据大小matlab
- delphi - 以前的工作程序突然开始时只有标题栏可见
- sql - 以向量为输入查询R中不同时间序列的函数
- laravel - 在单页应用程序中使用 JWT 令牌或/和会话的优势?
- python - reshape 的第三个参数是什么意思?
- pandas - 仅从日期时间列 pandas 中提取日期