Npm: module.js: 457 throw err; Error: cannot find "npmlog" module on mac using brew

I made a mistake (?) In the following instructions on the npm launch page and ran

sudo npm install npm -g

Now, no matter what I do, any npm execution results in this error, regardless of whether I run it as sudo or not. Removing and reinstalling node did not help.

$ sudo npm

module.js:457
    throw err;
    ^

Error: Cannot find module 'npmlog'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:13
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:75:3)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)

I am on a mac and am installing node using homebrew.

+4
source share
2 answers

Alexander O'Mara helped me solve this problem. Decision:

Run   brew uninstall --ignore-dependencies node node, , node.

,   brew uninstall --force node node , .

, , node :

rm -rf /usr/local/lib/node_modules
rm /usr/local/bin/npm
brew install node
+13

Linux-;

,

  • NPM < cd ~/node -v6.9.2-linux-x64/ → ( NODE Current LTS 6.9.2)

  • npm-cli.js lib/node_modules/npm/bin/npm-cli.js( cli.js npm-cli.js)

  • cd ~/ node -v6.9.2-linux-x64/bin

  • mv npm npm_old

  • ~/node -v6.9.2-linux-x64/bin ln -s PATH-TO/npm-cli.js npm

npm -v

PLUS npm npm install npm @latest -g

+1

Source: https://habr.com/ru/post/1654655/


All Articles