Hi everyone, I’m a neophyte and I’m learning to use node and npm.
In this regard, this morning I was initializing a folder
npm init when a warning appeared that a new version was available.
So I used the command:
sudo npm install -g npm.
Before doing this, the version of npm on my Mac was 6.9.0 and the version of node was 8.9.4.
After the update the version has become 6.10.0 but has stopped working. Running any command such as
npm init, or
npm install stylelint the command line returned the error:
MacBook-Pro-username:try username$ npm install stylelint npm ERR! code MODULE_NOT_FOUND npm ERR! Cannot find module './any.js' npm ERR! A complete log of this run can be found in: npm ERR! /Users/username/.npm/_logs/2019-07-08T11_07_07_324Z-debug.log
Then, failing to figure out how to update the node I launched the
brew install node command and it was an error because I probably didn’t install it via Homebrew (it’s been too long and I didn’t remember).
Now if I run the command
node --version it still gives me the old version, so it’s possible that now I have two versions of node. When I run the
npm init command, the error message has changed:
module.js:540 throw err; ^ Error: Cannot find module 'semver' at Function.Module._resolveFilename (module.js:538:15) at Function.Module._load (module.js:468:25) at Module.require (module.js:587: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:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3)
I know I’ve made a mess. I really don’t know how to get out of it so I thank you in advance for the help.