Search code examples
javascriptnode.jsnpm

npm ERR! code E401 npm ERR! Incorrect or missing password


My Node version is 10.15.0 and NPM version is 6.8.4 On running npm install after upgrading npm to 14.16.0 and npm to 7.6.2

Getting this error -

npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR!     https://www.npmjs.com/forgot
npm ERR! 
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR!     npm login

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/xyz/.npm/_logs/2021-04-15T18_55_07_993Z-debug.log

Solution

    1. Try Deleting the package-lock.json file before running the command "npm install" after upgrading the node versions, if you have not done that.

    2. If that will not work try removing the .npmrc file in $HOME directory as mentioned in this post.

    NPM ERR Code E401: Unable to authenticate, need: Bearer authorization

    Note - Deleting package-lock.json can have its own issues as mentioned in this posts, so go with this solution unless you find any better solution.

    Deleting `package-lock.json` to Resolve Conflicts quickly