Which npm version is correct? - npm

I just install npm 2.11.1,but when I use npm -v command it tells me the version is 2.10.1.
I want to know what's wrong and how can I handle it?
My computer is Windows operating system

If you install n you can update your npm to the latest stable version by this command
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
UPDATE :
for windows you can download and run the latest MSI. The MSI will update your installed node and npm.

Related

Why am I unable to install expo cli?

I have followed the documentation from Expo website, installed NodeJs, git, watachmann, however I m still getting errors when installing Expo cli:
First, ensure you use the recommended version of nodejs. For that, you can use the n module:
// if you haven't installed it before
sudo npm install n -g
//to have the latest stable version
sudo n stable
Then delete all your preview installs with npm and start over. For expo-cli:
sudo npm uninstall --global expo-cli
sudo npm install --global expo-cli

Why I can't get NPM upgraded?

Here is how I install NPM on a Linux Mint 19.
sudo apt install nodejs
sudo apt install npm
The NPM version I get is 3.5.2, which is not the current version. To upgrade, I try the following commands.
sudo npm install latest-version
which has a few warning messages such as "not such file or directory, open '/home/me/package.json'"
and
sudo mpn install npm#latest -g
which runs without any warning or error messages.
The command
npm -v
still yields 3.5.2.
What is missing?
Also, the reason of using sudo in those upgrade commands is to work around some access permission.
try running:
which npm
and
sudo which npm
I suspect by running sudo apt-get ... you installed npm for your root user as opposed to your current user.
Try this command: npm install -g npm#latest or npm install -g npm#next
You can update NPM with: npm install -g npm.
See this Q&A for more variations that might occur/needed.

SailsJS not updating

I haven't used sails in a long while and was about to start a new project but wanted to update my older 0.12.14 version to 1.0.2. I first tried doing
$ npm update -g
and then running
$ sails -v
This returned
0.12.14
Confused, I listed the npm global packages
$ npm list -g --depth=0
and this returned the list of global packages without sails.
I tried
$ npm uninstall sails -g
and when running
$ sails -v
or even
$ sails new test
it appeared to continue working. Checking the version in the package.json of the test project revealed that the old version was still alive and kicking. I'm out of ideas on how to update / uninstall sails.
To update Sails.JS, use npm install sails -g instead of npm update -g
If that isn't working, be sure to update to the latest npm & Node.JS:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
then
sudo npm install sails -g
To manually download and install Node.JS: https://nodejs.org/en/

how to install node 4.4.7 and npm 3.8.9?

By default node 4.4.7 comes with npm 2.15.8 version.
How can I modify npm version to 3.8.9 with same node version?
npm update #npm3.8.9 or upgrade didn't do.
Try like this
npm install npm#3.8.9
If you want to install latest version of npm
npm install npm#latest
here latest is the keyword
We can also upgrade node via npm
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
The n package represents a Node helper, and running the last command upgrades node to the latest stable version. Instead of using "stable", you could specify a desired version:
To upgrade, run: [sudo] npm install npm#latest -g if you don't want the latest provide the version number there

NPM -g update gives me many WARN dependency errors

Should I delete my node modules folder and reinstall everything again?
It appears that following David Walsh's way of updating Node has resolved my problem.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable