NPM insists on using the wrong registry URL

Viewed 1033

Using NPM to install dependencies, including one that is stored in Verdaccio running locally.

Somehow NPM is stuck attempting to load the Verdaccio dependency from localhost even though the command to install from the corrected location has been run npm install --save --registry http://CORRECT-URL ...

Using rm -rf node_modules package-lock.json and removing the dependency from package.json, then running the install again - still DOES NOT WORK. Every time the install command completes, package-lock.json STILL uses localhost to resolve the registry.

Removing localhost from ~/.npmrc and running npm set registry http://CORRECT-URL also didn't help.

Please help. Where is NPM remembering localhost and insisting on using it???

UPDATE - Using npm install -ddd

Attempted to use npm install -ddd to see where npm is picking up the package. The output shows the CORRECT-URL, but when it is done, package-lock.json still lists localhost.

Note all of the following:

  • Removed all references to the PACKAGE from package.json and package-lock.json
  • Verified no references to localhost in either file
  • Removed node_modules/PACKAGE_DIR with rm -rf
  • Removed PACKAGE from node_modules/.package-lock.json
  • Searched for .npmrc and npmrc in the build tree and found two empty files:
    • node/node_modules/npm/docs/public/configuring-npm/npmrc
    • node/node_modules/npm/.npmrc
  • ~/.npmrc has 2 entries for the CORRECT_URL in the following forms:
    • //:/:_authToken="<AUTH_TOKEN>"
    • registry=http://:/
1 Answers

Stumbled upon this post while trying to debug the exact same situation. What ended up solving this for me was to blow out package-lock, run npm rebuild, then npm install --registry . Hope this helps someone in the future!

Related