0

I was using npm few days ago and all worked fine, but I'm suddenly getting an error when trying to do any npm command.

module.js:487
throw err;
^

Error: Cannot find module 'readable-stream'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js:3:14)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)

I can't do any npm command, even npm -v show this error, node version is 8.0.0 I'm using latest version of macOS

One of the problems is that I didn't install node using homebrow so uninstalling and installing it again is the last solution for me.

Any help with this?

Gifron
  • 96
  • 1
  • 8
  • Yep, you gotta uninstall and reinstall Node to fix that – RyanZim Jun 13 '17 at 19:17
  • That's a bummer. Any tips how to uninstall all node files from system since it's been installed via pkg? – Gifron Jun 13 '17 at 19:31
  • sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*} This was able to solve my problem. After that I installed node with brew and it's working normally again. – Gifron Jun 13 '17 at 20:03

1 Answers1

0

When on a Mac, use nvm to install node, and switch node versions.

Also can nicely reinstall packages when upgrading versions. nvm install 6 --reinstall-packages-from=5

This is better than homebrew, which I would not suggest for Node on a Mac.

clay
  • 5,917
  • 2
  • 23
  • 21