0

I am running CentOS 6 and after logging in, I encounter the following error

  module.js:340
    throw err;
          ^
Error: Cannot find module 'npmlog'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at /home/dspace/.nvm/v0.10.31/bin/npm:19:11
    at Object.<anonymous> (/home/dspace/.nvm/v0.10.31/bin/npm:87:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v0.10.31 --silent` to unset it.

I've discovered that it is a version bug and can be resolved either by upgrading the npm version or by deleting the node modules like so;

rm -rf node_modules

Then reinstalling them;

npm install

After removing the modules, npm install failed to run because of missing dependancies i.e. the modules. Now the command shows no response at all.

My node version is v0.10.48

Samuel Mwamburi
  • 105
  • 2
  • 15
  • 1
    Possible duplicate of [Error "Cannot find module 'npmlog'" after "npm update -g"](https://stackoverflow.com/questions/34702617/error-cannot-find-module-npmlog-after-npm-update-g) – Sibeesh Venu Dec 21 '17 at 05:17

2 Answers2

1

This worked for me

  1. Install nvm: wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash

  2. Restart the terminal

  3. Run nvm install node

     

Samuel Mwamburi
  • 105
  • 2
  • 15
0

I had the same problem after proposed npm upgrade via npm -i -g npm. But Fedora npm/node installed via dnf has modules links to /usr/lib/node_modules/npm/node_modules.bundled/ from /usr/lib/node_modules/npm/node_modules/. I saw links were broken because usr/lib/node_modules/npm/node_modules.bundled/ disappeared. So reinstallation node,nodejs,npm via dnf/rpm solved the problem.

TMa
  • 723
  • 1
  • 5
  • 14