npm install error Cannot find module 'read-package-json.js'

Viewed 2425

enter image description here

when I install npm as above picture,the error messge show: Error: Cannot find module '/private/var/folders/dm/bzjdbz_s1z1bby3p087g0jr00000gn/T/npm.922/package/bin/read-package-json.js'

details see the pic.any tips?thanks

2 Answers

Here's how I solved it:

    echo prefix=~/.npm-packages >> ~/.npmrc
    wget https://registry.npmjs.org/npm/-/npm-5.5.1.tgz
    tar xf npm-5.5.1.tgz
    cd package
    ./npm-cli.js install npm -g

You can follow the following steps:

brew uninstall --force node
brew update
brew upgrade
brew cleanup
brew install node
sudo chown -R $(whoami) /usr/local  #may not work
brew link --overwrite node
sudo brew postinstall node     #may not work

You may face problems with sudo, but no worries it should work without it :)

Related