Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "Cannot find module 'npmlog'" after "npm update -g"

Tags:

node.js

npm

nvm

I have NVM 0.30.1 and used it to install node.js v5.4.0 (with NPM 3.5.4) on Fedora 22. When I run npm update -g, I receive the following warnings:

npm WARN EBUNDLEOVERRIDE Replacing bundled npm > init-package-json with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > node-gyp with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > npm-install-checks with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > npmlog with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > read-package-json with new installed version

And after that, when I run npm I get this error:

module.js:328
    throw err;
    ^

Error: Cannot find module 'npmlog'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at /home/peflorencio/.nvm/versions/node/v5.4.0/lib/node_modules/npm/bin/npm-cli.js:20:13
    at Object.<anonymous> (/home/peflorencio/.nvm/versions/node/v5.4.0/lib/node_modules/npm/bin/npm-cli.js:76:3)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)

Does anyone know what it is and how to solve it?

Thanks

like image 923
peflorencio Avatar asked Jan 10 '16 06:01

peflorencio


5 Answers

Thanks for the answers. It was a bug and it has already been fixed in Node v5.4.1. Now it's working as usual.

like image 154
peflorencio Avatar answered Oct 24 '22 01:10

peflorencio


What fixed this for me was

sudo rm -rf /usr/local/lib/node_modules/

and then re-installing node (with npm).

like image 43
Alan H. Avatar answered Oct 23 '22 23:10

Alan H.


It looks like npm update -g cannot update npm to the newest version. I solve the problem by updating npm installation manually.

  1. Install/ reinstall node to get the bundled npm
  2. run npm install -g [email protected] to update the global npm installation
  3. now npm update -g should work
like image 42
motou Avatar answered Oct 24 '22 00:10

motou


I have faced the same issue in my Windows 10 PC. After looking into solutions, since i couldn't find the exact solution for the issue i was facing Cannot find module 'npmlog' I just uninstalled the node js and then, deleted both 'npm' and 'npm-cache' in "C:\Users\YourPCName\AppData\Roaming"

Then, i downloaded the latest version of node from Node JS Website

And, installed node js

After that i checked with the path in environment variables.

Finally run the command prompt 'run as administrator' and npm install npm -g

Checking your version will show the latest version. 'npm -v'

I got the latest version - v3.10.9

Try this. this should work.

like image 3
Saiyaff Farouk Avatar answered Oct 24 '22 00:10

Saiyaff Farouk


If people with linux are facing the problem, here is the solution:

As of the date of this post, the NPM version packaged with Nodejs doesn't work. If you installed this package, run

sudo rm -rf /usr/local/bin/npm
sudo apt-get install node
sudo mv /usr/bin/npm /usr/local/bin/npm

New version should be 3.10.8 and the old error gone

like image 2
hithere Avatar answered Oct 23 '22 23:10

hithere