npm install – Cannot find module ‘semver’ issue

I have recently got an error “Cannot find module ‘semver'” on my Ubuntu VM when doing npm install.

+ npm install
...
...
module.js:340
    throw err;
          ^
Error: Cannot find module 'semver'

 

I have tried various things but nothing worked out. Then I have done the below things and it resolved my issue.

sudo apt-get remove nodejs

sudo apt-get remove npm

sudo apt-get update 

sudo apt-get install nodejs

sudo apt-get install npm

sudo ln -s /usr/bin/nodejs /usr/bin/node

npm install

 

Advertisements