简体   繁体   English

npm 安装私有仓库时出现安装错误401

[英]npm install error 401 when installing a private repository

I am having some issues with NPM and looking for some guidance.我在使用 NPM 时遇到一些问题并寻求一些指导。 When I run the command npm i , I get the following error:当我运行命令npm i时,我收到以下错误:

npm ERR! code E401
npm ERR! 401 Unauthorized - GET https://URL-HERE - Your request could not be authenticated by the GitHub Packages service. Please ensure your access token is valid and has the appropriate scopes configured.

When I run npm whoami , I see my npm username.当我运行npm whoami时,我看到了我的 npm 用户名。 When I run npm token , I see a complete list of my tokens (including tokens that should give me permission to install the necessary libraries included in my package.json file. In addition, I have removed any .npmrc files from the repository that I am trying to build.当我运行npm token时,我看到了我的令牌的完整列表(包括应该允许我安装package.json文件中包含的必要库的.npmrc 。我正在努力建造。

I have read through this thread from 2018: NPM install resulting in 401 Unauthorized for private repo .我从 2018 年开始通读此线程: NPM install 导致 401 Unauthorized for private repo However, I have not had any luck with any of the suggestions.但是,我对任何建议都没有运气。 Any additional ideas or things that I should investigate?我应该调查任何其他想法或事情吗?

I found either a solution or a workaround.我找到了解决方案或解决方法。 The following resource was particularly helpful for me:以下资源对我特别有帮助:

First, generate an access token on your GitHub account.首先,在您的 GitHub 帐户上生成访问令牌。 Then, enter the command npm login --scope=@OWNER --registry=https://npm.pkg.github.com .然后,输入命令npm login --scope=@OWNER --registry=https://npm.pkg.github.com Enter your standard username, your GitHub token as your password , and your email address.输入您的标准用户名,您的 GitHub 令牌作为您的密码,以及您的 email 地址。 Run npm install again, and your modules should be installed.再次运行npm install ,你的模块应该已经安装好了。 Here is the example from the GitHub guide:以下是 GitHub 指南中的示例:

$ npm login --scope=@OWNER --registry=https://npm.pkg.github.com

> Username: USERNAME
> Password: TOKEN
> Email: PUBLIC-EMAIL-ADDRESS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM