Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. After that I am not able to run npm install, as I'm getting this error

 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.

like image 228
Rahul Dole Avatar asked May 05 '20 13:05

Rahul Dole


11 Answers

I had similar issue. I resolved it by adding _auth into my ~/.npmrc. See the doc how to encode your nexus credential. I added the encoded credential using npm config set _auth xxx.

You wont be able to see the value using npm config list or npm config get _auth.

like image 170
Zee Avatar answered Oct 01 '22 02:10

Zee


what worked for me is :

I deleted the .npmrc file under C/users/ folder. and ran npx vsts-npm-auth -config .npmrc command to create a new file in the users folder

like image 45
Anushree Garg Avatar answered Oct 03 '22 02:10

Anushree Garg


In my case, the problem was I've entered another registry address in same Nexus for npm login command.

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
like image 35
Ahmet Emre Kılınç Avatar answered Oct 02 '22 02:10

Ahmet Emre Kılınç


  1. Deleted the .npmrc file under C/users/ folder
  2. npm set registry=http....
  3. npm set _auth=(login:pass in base64):
like image 43
Lexa Avatar answered Oct 01 '22 02:10

Lexa


I found a way out. With this new npm version they are enforcing authentication to access certain packages. 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.

like image 30
Rahul Dole Avatar answered Oct 03 '22 02:10

Rahul Dole


vsts-npm-auth -config .npmrc -F

Is the only solution I found;

Edit: make sure to run npm install -g vsts-npm-auth before

like image 44
Timtim Avatar answered Sep 30 '22 02:09

Timtim


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.

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. The AzDo UI reported my token as still being valid.

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.

like image 2
derekbaker783 Avatar answered Oct 03 '22 02:10

derekbaker783


What worked for me was running npm login, then entering my Username, Password, and Email to log in to the registry defined in .npmrc. I then proceeded with npm installing the packages I needed and it worked.

like image 2
George. Avatar answered Oct 03 '22 02:10

George.


I'm run set's command from the post and add in nexus "Active realms" profile "npm Bearer Token Realm". Links: https://help.sonatype.com/repomanager3/system-configuration/access-control/realms My problem was solved.

like image 2
vergiz Avatar answered Oct 02 '22 02:10

vergiz


In my case the Nexus Authentication and project I am using requires Node version: 12.8.1.

I was using node version: 16.13.2

I use NVM to install 12.8.1 with nvm install 12.8.1 Then nvm use 12.8.1

This will now work on my machine and environment.

like image 1
cshdev Avatar answered Oct 01 '22 02:10

cshdev


You can remove package-lock.json .. it works with me

like image 2
Magdy Elsayyad Avatar answered Oct 02 '22 02:10

Magdy Elsayyad