MichaelB
MichaelB

Reputation: 1362

How to fix: npm ERR! Cannot find module 'read-package-json'

I made a horrible mistake and run this command:

sudo npm update -g npm

As a result npm was rendered useless, any attemps to install anything results in the following error :

npm ERR! Darwin 15.0.0
npm ERR! argv "/Users/michaelb/.nvm/versions/node/v5.3.0/bin/node" "/Users/michaelb/.nvm/versions/node/v5.3.0/bin/npm" "install"
npm ERR! node v5.3.0
npm ERR! npm  v3.7.4
npm ERR! code MODULE_NOT_FOUND

npm ERR! Cannot find module 'read-package-json'
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

Can anyone speculate what is the problem and how to fix it ?

Im using OS X El Capitan (10.11)

node -v
v5.3.0

npm -v
3.7.4

nvm ls
->       v5.3.0
default -> stable (-> v5.3.0)
node -> stable (-> v5.3.0) (default)
stable -> 5.3 (-> v5.3.0) (default)
iojs -> N/A (default)

Upvotes: 2

Views: 4360

Answers (3)

David Raleche
David Raleche

Reputation: 476

All npm issues such as :


  • Error: Cannot find module 'interpret'
  • Error: Cannot find module 'read-pkg-up'
  • Error: Cannot find module 'lru-cache'

Solution


  1. Delete file :

package-lock.json

  1. Run in the terminal

$npm upgrade

Upvotes: 0

McAgee
McAgee

Reputation: 148

In my case, my node was installed by the .pkg file. And I reinstall npm didn't work. I solved this problem by uninstall the node totally follow this gist: https://gist.github.com/TonyMtz/d75101d9bdf764c890ef

Upvotes: 1

kantuni
kantuni

Reputation: 961

Just found in their GitHub issues

Reference:

Solution: Reinstall npm

Upvotes: 1

Related Questions