简体   繁体   English

npm 错误 E401:无法验证,需要:BASIC realm="Sonatype Nexus Repository Manager"

[英]npm error E401: Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"

I upgraded node version to 12.16.2 and npm version to 6.14.4.我将节点版本升级到 12.16.2,将 npm 版本升级到 6.14.4。 After that I am not able to run npm install , as I'm getting this error之后我无法运行npm install ,因为我收到此错误

 code E401
 npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"

I even tried deleting node_modules and package-lock.json and running npm install again, but doesn't change anything.我什至尝试删除 node_modules 和 package-lock.json 并再次运行 npm install,但没有任何改变。

I had similar issue.我有类似的问题。 I resolved it by adding _auth into my ~/.npmrc .我通过将_auth添加到我的~/.npmrc中来解决它。 See the doc how to encode your nexus credential .请参阅文档如何编码您的关系凭证 I added the encoded credential using npm config set _auth xxx .我使用npm config set _auth xxx添加了编码凭证。

You wont be able to see the value using npm config list or npm config get _auth .您将无法使用npm config listnpm config get _auth查看值。

In my case, the problem was I've entered another registry address in same Nexus for npm login command.就我而言,问题是我在同一个 Nexus 中为npm login命令输入了另一个注册表地址。

npm login --registry=http://nexus_url:port/repository/wrong_address

My problem was solved by logging into correct address:通过登录正确的地址解决了我的问题:

npm login --registry=http://nexus_url:port/repository/correct_address

what worked for me is:对我有用的是:

I deleted the.npmrc file under C/users/ folder.我删除了 C/users/ 文件夹下的 .npmrc 文件。 and ran npx vsts-npm-auth -config.npmrc command to create a new file in the users folder并运行 npx vsts-npm-auth -config.npmrc 命令在用户文件夹中创建一个新文件

I found a way out.我找到了出路。 With this new npm version they are enforcing authentication to access certain packages.有了这个新的 npm 版本,他们正在强制进行身份验证以访问某些包。 We realised we don't need to use authentication for any of the packages we were downloading, hence the auth code we had was unnecessary.我们意识到我们不需要对我们正在下载的任何包使用身份验证,因此我们拥有的身份验证代码是不必要的。 So we just removed it and it all worked.所以我们只是删除了它,这一切都奏效了。

  1. Deleted the.npmrc file under C/users/ folder删除了 C/users/ 文件夹下的 .npmrc 文件
  2. npm set registry=http.... npm 设置注册表=http....
  3. npm set _auth=(login:pass in base64): npm set _auth=(login:pass in base64):
vsts-npm-auth -config .npmrc -F

Is the only solution I found;是我找到的唯一解决方案;

Edit: make sure to run npm install -g vsts-npm-auth before编辑:确保在之前运行npm install -g vsts-npm-auth

I encountered this error when running an npm install that was pulling some dependencies from a non-public registry located on a self-hosted Azure DevOps (AzDo) server.我在运行npm install时遇到此错误,该安装从位于自托管 Azure DevOps (AzDo) 服务器上的非公共注册表中提取一些依赖项。

I had a .npmrc file in the project, and a .npmrc file in my user profile dir with an AzDo personal access token (PAT) that had allowed access previously.我在项目中有一个.npmrc文件,在我的用户配置文件目录中有一个.npmrc文件,其中包含以前允许访问的 AzDo 个人访问令牌 (PAT)。 The AzDo UI reported my token as still being valid. AzDo UI 报告我的令牌仍然有效。

PS C:\src\app> npm install
npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="{INTERNAL_REGISTRY_URL}", Negotiate, NTLM

In my case, the solution was to regenerate the AzDo PAT and update the .npmrc found in my user profile directory.就我而言,解决方案是重新生成 AzDo PAT 并更新在我的用户配置文件目录中找到的.npmrc

What worked for me was running npm login , then entering my Username, Password, and Email to log in to the registry defined in .npmrc .对我有用的是运行npm login ,然后输入我的用户名、密码和 Email 以登录到.npmrc中定义的注册表。 I then proceeded with npm installing the packages I needed and it worked.然后我继续使用 npm 安装我需要的软件包并且它工作正常。

I'm run set's command from the post and add in nexus "Active realms" profile "npm Bearer Token Realm".我从帖子中运行 set 的命令并添加 nexus “Active realms”配置文件“npm Bearer Token Realm”。 Links: https://help.sonatype.com/repomanager3/system-configuration/access-control/realms My problem was solved.链接: https://help.sonatype.com/repomanager3/system-configuration/access-control/realms我的问题解决了。

In my case the Nexus Authentication and project I am using requires Node version: 12.8.1.在我的情况下,我使用的 Nexus 身份验证和项目需要节点版本:12.8.1。

I was using node version: 16.13.2我使用的是节点版本:16.13.2

I use NVM to install 12.8.1 with nvm install 12.8.1 Then nvm use 12.8.1我使用 NVM 安装 12.8.1 和nvm install 12.8.1然后nvm use 12.8.1

This will now work on my machine and environment.这现在可以在我的机器和环境上运行。

You can remove package-lock.json.. it works with me您可以删除 package-lock.json .. 它适用于我

Had the same issue while doing npm i for a private npm registry.在为私有 npm 注册表执行npm i时遇到同样的问题。 Solved it by removing the _authToken parameter from some lines in my .npmrc file in my user's root directory:通过从用户根目录中的.npmrc文件中的某些行中删除_authToken参数来解决此问题:

Before:前:

//registry.npm.example.com/:_authToken=NpmToken.XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX
//npm.artifacts.example.io/:_authToken=NpmToken.XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX
update-notifier=false
registry=https://npm.artifacts.example.io/

After:后:

//registry.npm.example.com/
//npm.artifacts.example.io/
update-notifier=false
registry=https://npm.artifacts.example.io/

My problem was solved by after add in nexus "Active realms" profile "npm Bearer Token Realm".添加nexus“Active realms”配置文件“npm Bearer Token Realm”后,我的问题得到了解决。 Links: https://help.sonatype.com/repomanager3/system-configuration/access-control/realms链接: https://help.sonatype.com/repomanager3/system-configuration/access-control/realms

In my case, npmjs expected a Base64 encoded Personal Access Token in the .npmrc file, and I had forgotten to Base64 encode it before pasting it into the user .npmrc file.就我而言,npmjs 期望在.npmrc文件中使用 Base64 编码的个人访问令牌,而我忘记在将其粘贴到用户.npmrc文件之前对其进行 Base64 编码。

I also faced the same issue while creating a new project and downgraded my current node version, 16, to 14.20.0.在创建新项目并将当前节点版本 16 降级到 14.20.0 时,我也遇到了同样的问题。 My steps to fix this issue.我解决此问题的步骤。

  1. Earlier I had configured NODE_HOME under "Environment variable".之前我在“环境变量”下配置了 NODE_HOME。
  2. I removed it.我删除了它。
  3. Only configured the path.只配置了路径。
  4. Created a new folder in the "C" drive and pasted the node files.在“C”驱动器中创建一个新文件夹并粘贴节点文件。
  5. (System variable)Path = "C:\Node\node-v14.20.0-win-x64" (系统变量)Path = "C:\Node\node-v14.20.0-win-x64"

I had same issue as I had configured my auth through the.npmrc file by adding the below details to it:我遇到了同样的问题,因为我通过向 .npmrc 文件添加以下详细信息来配置我的身份验证:

_auth=xxx
always-auth=true
email=example@mail.com

The error was: npm ERR, code E401 npm ERR: Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"错误是:npm ERR,代码 E401 npm ERR:无法验证,需要:BASIC realm="Sonatype Nexus Repository Manager"

then got resolved after removing underscore (_) from auth in the.npmrc file:然后在从.npmrc文件中的auth中删除下划线(_)后得到解决:

auth=xxx
always-auth=true
email=example@mail.com

if the.npmrc file config like this如果 .npmrc 文件配置是这样的

//registry.npm.example.com/:_auth="base64(username:psw)"

try this尝试这个

//registry.npm.example.com/:_authToken="base64(username:psw)"

We are facing same issue with Github npm error E401: Unable to authenticate, need: BASIC realm="GitHub" while installing npm packges via npm install --force in react application React v18,node v16 .This issue got resolved for us when we change git configution.Here are the steps we followed-我们面临与 Github npm error E401: Unable to authenticate, need: BASIC realm="GitHub"同时通过 npm install npm install --force in react application React v18,node v16 。当我们解决这个问题时更改 git 配置。以下是我们遵循的步骤 -

  1. Inside Credential Manager -Delete all saved/cached credentials for windows user内部凭据管理器 - 删除 windows 用户的所有已保存/缓存的凭据
  2. Changing the windows as well as Git credentials in git.config在 git.config 中更改 windows 以及 Git 凭据
  3. Cloning the repo again再次克隆回购
  4. always-auth=true - in.npmrc file always-auth=true - 在.npmrc 文件中
  5. removed package-lock.json删除包锁.json
  6. npm install --force npm 安装 --force

tried all answers, but no success.尝试了所有答案,但没有成功。 our project has its own npmrc and npm read exactly this one, but not that from user folder.我们的项目有自己的 npmrc 和 npm 准确读取这个,而不是从用户文件夹中读取的。 i temporarily removed project npmrc, instal packeges ant restore file我暂时删除了项目 npmrc,安装 packeges ant 恢复文件

In such case you can try:
changing details in

**1  .npmrc**
My issue resolved by updating the details in this file. So you too can try it, just by editing values:

registry=https://nexus.............../
strict-ssl=false
always-auth=true
email= your email address
_auth=** (** mean details obtained from cmd or browser console.)



**2. Package.json:**
"jasmine-core": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0" not necessary to match this use one that are provided in your error message.


**3. delete pack`enter code here`age-lock.json**
You can delete this file and hit npm install (don't know how helpful this command is but you can try. As this cmd will recreate package-lock.json

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

相关问题 节点版本升级 npm ERR, Unable to authenticate: need: BASIC realm="Sonatype Nexus Repository Manager" - Node version upgrade npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager" NPM ERR代码E401:无法认证,需要:承载授权 - NPM ERR Code E401: Unable to authenticate, need: Bearer authorization 尝试连接到 Azure DevOps 工件时“无法验证”通过 npm 馈送; 我收到 E401 错误 - 'Unable to Authenticate' when trying to connect to Azure DevOps Artifacts feed through npm; I get an E401 error E401 - 无法验证,您的验证令牌似乎无效 - E401 - Unable to authenticate, your authentication token seems to be invalid 运行“npm install”会导致“npm ERR! 代码 E401' - Running 'npm install' causes a 'npm ERR! code E401' Lerna boostrap 因 npm ERR 而失败! 代码 E401 - Lerna boostrap fails with npm ERR! code E401 npm ERR,无法验证:需要:Basic realm="https.//pkgsprodsu3weu.app.pkgs.visualstudio.com/" - npm ERR! Unable to authenticate, need: Basic realm="https://pkgsprodsu3weu.app.pkgs.visualstudio.com/" npm 错误,代码 E401,密码错误或丢失 - npm Err! code E401, Incorrect or missing password Sonatype Nexus OSS无法加载nexus-npm-repository-plugin - Sonatype Nexus OSS fails to load nexus-npm-repository-plugin 错误! 代码 E401 npm 错误! 密码不正确或丢失 - npm ERR! code E401 npm ERR! Incorrect or missing password
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM