node.jsnpmnpm-install

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.


Solution

  • 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.