首页 > 解决方案 > 如何使用 Auth Token 将作用域 npm 包发布到私有 Bytesafe npm 注册表

问题描述

我正在尝试使用 AUTH TOKEN 编写我的第一个 npm 包并测试发布到我的私有 bytesafe npm 注册表,然后再继续并合并来自 CI 管道的发布。

我已经登录到我的 bytesafe 目录并获得了一个 TOKEN:

npm --registry https://<<my.bytesafe.registry string goes here>> login with User: bytesafe Password: <passwd>
npm --registry https://<<my.bytesafe.registry string goes here>> token create Password: <passwd> 

我创建了我的 ~/.npmrc 文件,如下所示:

//<<my.bytesafe.registry string goes here>>/:_authToken=${NPM_TOKEN}
registry=https://<<my.bytesafe.registry string goes here>
email=<my email addess>
always-auth=true

我的package.json

{
  "name": "@spears/tryitandsee",
  "version": "1.0.1-0",
  ...
  "publishConfig": {
    "registry": "https://<my.bytesafe.registry string goes here>"
  }
}

当我运行npm publish时,我收到以下错误消息:

npm ERR! code E401
npm ERR! 401 Unauthorized - PUT https://<my.bytesafe.regsitry string goes here>/@spears%2ftryitandsee - Access Denied

如何使用身份验证令牌发布到私有 npm 注册表?

解决了!这是一个错字问题!

标签: npm

解决方案


支持将作用域包发布到私有注册表,因此这很可能与过期令牌有关。

希望您已经设法解决了您的问题。如果您的私有注册表仍然存在问题,我建议您通过https://bytesafe.dev联系支持人员,因为我们很乐意帮助您解决问题。

/Martin,字节安全团队


推荐阅读