从github npm注册表安装软件包-身份验证错误401 [英] Installing packages from github npm registry - auth error 401
问题描述
我刚刚在GitHub上发布了一个私有软件包,试图弄清楚它应该如何工作.现在我正在尝试将其安装在另一个项目中.我使用具有write:packages
,read:packages
和repo
特权的访问令牌通过npm login --registry=https://npm.pkg.github.com
进行了身份验证.尝试运行npm install https://npm.pkg.github.com/@orgname/package-name
时,出现错误消息:
I have just published a private package on GitHub, trying to figure out how it should be working. now I'm trying to install it in another project. I authenticated with npm login --registry=https://npm.pkg.github.com
with an access token that has write:packages
, read:packages
and repo
privileges. While trying to run npm install https://npm.pkg.github.com/@orgname/package-name
I get an error message:
npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"
如何添加/获取此特权?
How can I add/get this privilege?
推荐答案
显然我是个白痴,看不懂文档,却错过了这一部分:
Apparently I'm an idiot who can't read documentation and missed that part:
在与
package.json
文件相同的目录中,创建或编辑.npmrc
文件,以包含指定GitHub Packages URL和帐户所有者的行.将OWNER替换为拥有包含您的项目的存储库的用户或组织帐户的名称.
In the same directory as your
package.json
file, create or edit an.npmrc
file to include a line specifying GitHub Packages URL and the account owner. Replace OWNER with the name of the user or organization account that owns the repository containing your project.
registry=https://npm.pkg.github.com/OWNER
这篇关于从github npm注册表安装软件包-身份验证错误401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!