Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM : Cannot find module 'node-gyp/bin/node-gyp'

Tags:

I'm using NPM under my ubuntu 14.04 and node 8.0.0 .

I have upgraded my npm from 5.2.0 to 5.6.0

but after that all npm commands are failing , indicating a problem of :

node-gyp/bin/node-gyp

The complete log is the following :

npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'node-gyp/bin/node-gyp'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/khalidvm/.npm/_logs/2018-01-12T15_02_35_338Z-debug.log
khalidvm@ubuntu:~/Desktop$ gedit /home/khalidvm/.npm/_logs/2018-01-12T15_02_35_338Z-debug.log
^C
khalidvm@ubuntu:~/Desktop$ sudo npm uninstall npm -g
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module 'node-gyp/bin/node-gyp'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/khalidvm/.npm/_logs/2018-01-12T15_05_25_322Z-debug.log

I'm afraid that I'm not able to use npm , even uninstalling it, throws that same error.

like image 862
firasKoubaa Avatar asked Jan 12 '18 15:01

firasKoubaa


2 Answers

If you're running the default installation of node on Ubuntu 14.04, the package should be out of date (I believe it's a 0.xx version) and be the source of your problems. You can fix that by looking here: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

Working with an up-to-date distribution of node, I had the same problem with node-gyp. It turned out that I had a ghost installation under /usr/local. That was ghosting my node executable.

After deleting it by running:

  sudo rm -rf /usr/local/bin/node-gyp 
  sudo rm -rf /usr/local/bin/npm
  sudo rm -rf /usr/local/bin/npx
  sudo rm -rf /usr/local/lib/node_modules/

and cleaning node files in my home directory, for precaution:

  rm -rf ~/.node-gyp/
  rm -rf ~/.npm/

I uninstalled the current node installation, and reinstalled:

sudo apt-get remove --purge nodejs
sudo apt-get install nodejs
like image 84
spac Avatar answered Oct 10 '22 17:10

spac


For me (Arch Linux) it was enough to install node-gyp via pacman:

sudo pacman -Sy node-gyp

For Arch see: https://www.archlinux.org/packages/community/any/node-gyp/

sudo apt-get install node-gyp

For Ubuntu see: https://packages.ubuntu.com/de/trusty/web/node-gyp

like image 38
Code NKasch Avatar answered Oct 10 '22 15:10

Code NKasch