Error: Cannot find module 'semver'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
Cannot find module ‘XXXXX’ has encountered this problem,
I have tried:
npm install semver
npm install -g socket.io
This is not going to work.
and then find another solution.
first see if your NPM is useful. Check method: open the terminal and enter
npm -v
If the error is reported, then it is necessary to re-install NPM. First, the original NPM is deleted. The method is:
, you can go to the global NPM package to have a look, the path is:
/usr/local/lib/node_modules/npm
Go to the Semver folder in NOde_modules in NPM and you’ll see that it’s empty! Or no, we will know why semver module can not be found!
1. First delete the global NPM package: just mentioned /usr/local/lib/node_modules/ NPM, this NPM folder delete
2. Go to /usr/local/lib/node_modules and clone git from GitHub
git clone --recursive git://github.com/isaacs/npm.git
This brings the new NPM package back to global node_modules
.
npm -v
Check it in the terminal. If you can print it out, that’s fine.