npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Error: Cannot find module './auth.js'

After updating to npm I get this error with every npm command I try:
Error: Cannot find module ‘./auth.js’
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/index.js:7:17)
at Module._compile (module.js:653:30)
at Object.Module._extensions…js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)

Please use the bug template in the future. As you probably can’t see it now, the template mostly asks for reproduction steps (which aren’t really relevant in this case), and what versions (npm --version) and what platform (node -p process.platform) you have. I also recommend formatting error logs as code for reading purposes and to avoid “smart” transformations such as smart quotes, ellipsis and removed backslashes. You can do this by selecting the text and click on the </> button.

Either way, it looks like your installation of npm is broken and some files are missing. Reinstalling should probably fix it. I see other people had this problem recently as well, did you install it from an unusual source?

Sorry, I skipped the template as anything I did only resulted in the same error. Even running npm --version gave the error.
I updated npm using npm update -g npm

I managed to install npm 6.4 (came with node v10) and all works well now.
Thanks for the quick reply.

Right, I didn’t think about that :slight_smile:


The docs recommend this command instead (although it shouldn’t matter much):

npm install -g npm@latest

I am currently experiencing this issue after i update npm using npm install -g npm@latest. How can I fix this in mac? is there a way to rollback the update?

Update nodejs, it will update npm and that’s it!