2

while trying to install a gulp package, i had this error message.

module.js:471
throw err;
^

Error: Cannot find module './auth.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> 
(/usr/local/lib/node_modules/npm/node_modules/npm-registry- 
fetch/index.js:7:17)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

Upon trying further i realised that i could not execute any other npm commands. It always showed this message. How can i fix this problem?

I have even tried doing this,

sudo rm -rf node_modules
npm install

But i always end up with this message again.

Thank you.

schenker
  • 941
  • 3
  • 12
  • 25

2 Answers2

1

This helped me

sudo n stable

Answer source: How can I update NodeJS and NPM to the next versions?

schenker
  • 941
  • 3
  • 12
  • 25
  • This helps, because 'n' is a Node version switcher, which means it switches you to a new version of Node (which includes a different version of NPM). So it's the same fix as the other answer, but quite convenient. – David Cook Mar 27 '19 at 22:27
1

Your installation of npm is probably broken. I had the same issue after updating npm to 6.8.0 Normally, you would install a different version for npm using npm, but as that isn't going to work, you could download the NodeJs installer (from nodejs.org) and reinstall NodeJs. It (currently) comes with npm 6.4 which worked for me.

Fred
  • 512
  • 3
  • 6