Node and NPM versions don't match - node.js

The node and npm versions on my mac dont match. How do I downgrade npm to the same version as node?
Node:
$ node -v
$ v0.12.7
NPM:
$ npm -v
$ 2.14.4

npm is a package manager for node.js. They don't have to be the same version. npm also gets updated more frequently than node, so they could not be expected to keep their versions the same

If it helps, you can install any version of NPM. On debian distros, to use npm version 4.5.0 you need to do:
$ curl https://registry.npmjs.org/npm/-/npm-4.5.0.tgz
$ tar -xvzf npm-4.5.0.tgz
$ cd package/
$ [sudo] make install

Their versions are different because they are independent softwares. Their development is not synchronized.
I recommend updating NPM when you can; I'm running npm version 5.2.0
You can easily upgrade your NPM version using npm install -g npm

Related

Downgrade Nodejs and Npm

Hello everyone how i can downgrade my version of nodejs and npm under ubuntu ?
Thanks,
You can downgrade npm by simple pasting a needed version:
For example:
npm install -g npm#3.10.10
Be sure that it's downgraded:
npm -v
To downgrade nodejs, you can also do so by simple pasting a needed version.
For example:
$ npm install -g n
$ n 6.10.3
Be sure that it's downgraded:
$ node -v
v6.10.3

Can't install latest angular cli on ubuntu

I'm trying to install angular via ubuntu.
When I type the version commande node -v
I get v12.14.1
Then I try to install npm package sudo npm install -g #angular/cli
I get a warning
npm WARN npm npm does not support Node.js v10.15.2
ng version
I get angular-cli: 1.0.0-beta.28.3
The npm version is 6.13.4
The issue here seems to be that sudo node -v gives 10.15.2 where as node -v gives 12.14.1.
This means that there are 2 different node versions installed.
You can get around this by using sudo -E node -v or by deleting the link to the other node.js install by doing: rm /usr/local/bin/node.

npm does not support Node.js v9.0.0

I just upgraded my project to use Node.js v9.0.0. When I start my project using npm, it tells me I should upgrade to a newer Node version, but I believe this is the newest version. I also believe I'm on the newest version of npm (5.5.1).
Do I need to worry about this warning? Is there a good way to resolve the issue?
Here's the full warning:
npm WARN npm npm does not support Node.js v9.0.0
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
Now using node v9.0.0 (npm v5.5.1)
I've just upgraded to Node v9 and ran into the same issue. There's a Github issue for this here.
Following the advice to uninstall a global instance of npm has resolved the issue for me, using:
npm uninstall -g npm
With Node 10.6.0 on Windows 10 with Git Bash installed, I did this and all worked well:
1. Launch Git Bash terminal.
2. cd ~/AppData/Roaming
3. rm -rf npm
4. rm -rf npm-cache
5. npm install -g npm#latest
Check version and test on an existing project to verify (cd to project dir)...
6. npm -version
7. npm install
NB: Performing steps 2 through 4 via Windows Explorer could be faster.
9.0.0 is indeed the latest version available at the moment. The reason that NPM shows you this message is because NPM hasn't updated their unsupported.js yet to accept 9.0.0 as a supported version.
I would say that you can probably use it without problems, but if you stumble upon one, know that it's probably caused by a breaking change in Node.js 9.0.0 and will very likely be fixed by the NPM team soon.
npm does not support Node.js v9.1.0
Uninstall did not work for me
npm uninstall -g npm
Node.js v9.1.0 comes bundled with npm v5.5.1. The latest version of npm is also v5.5.1, however, the version bundled with Node.js isn't exactly the same as the original version from npm.
The following is what I needed to do on MacOS
To completely uninstall node + npm, do the following:
1. go to /usr/local/lib and delete any node and node_modules.
2. go to /usr/local/include and delete any node and node_modules directory.
3. download and install node from nodejs.org
Latest update Jan 2018: NPM has released version 5.6.0 to work with this.
How to upgrade npm:
Note if you are using node version 9 you will not be able to upgrade npm directly, since npm does not support version 9, so using nvm, downgrade node to latest stable release, that will make npm work, then use commandnpm install -g npm#latest to upgrade npm.
Install nvm:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash\n
export NVM_DIR="$HOME/.nvm"\n[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
Download and use node X version:
nvm install 4.4.2
nvm use 4.4.2
node -v
[sudo] npm install -g npm#5.3.x remove this problem for me. ubuntu 16.10

installed latest version of node -- but npm is broken (mac)

OK so, I went to the nodejs.org webpage, downloaded node version 7.5.0, installed it using the easy to use wizard.
It installed with no errors or issues.
When I open up my terminal, node -v gives me v7.5.0, and npm -v gives me 3.6.0.
Obviously I want the latest version of npm, so I go to npm install npm#latest -g, but I get this error:
Cannot find module 'internal/fs'
In fact, trying to install ANYTHING using npm results in the same error.
How do I fix npm?
Try uninstalling your current node version and reinstall using nvm or brew:
To find where node lives: command -v node && command -v npm
Remove these directories as stated in some of the comments here: https://github.com/nodejs/node/issues/9377
Posting this for anyone passing by. You can use npm up -g to update the npm version. Here's output from my console installing node 4.7.3 via nvm:
user#localhost:~/Desktop/demo$ nvm install 4.7.3
Downloading and installing node v4.7.3...
Downloading https://nodejs.org/dist/v4.7.3/node-v4.7.3-darwin-x64.tar.gz...
######################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v4.7.3 (npm v2.15.11)
user#localhost:~/Desktop/demo$ npm up -g
/Users/user/.nvm/versions/node/v4.7.3/bin/npm -> /Users/user/.nvm/versions/node/v4.7.3/lib/node_modules/npm/bin/npm-cli.js
npm#4.2.0 /Users/user/.nvm/versions/node/v4.7.3/lib/node_modules/npm
user#localhost:~/Desktop/demo$ npm -v
4.2.0
user#localhost:~/Desktop/demo$

npm update fires off successfully, but doesn't actually upgrade npm -v

This is on a Macbook
I execute sudo npm install -g npm and get this following output:
/Users/myUser/.npm-packages/bin/npm -> /Users/myUser/.npm-packages/lib/node_modules/npm/bin/npm-cli.js
npm#3.10.8 /Users/myUser/.npm-packages/lib/node_modules/npm
However, when I restart terminal and npm -v, I still get 2.15.9
The nvm tool is most commonly used for managing Node versions and upgrades. Follow the directions here for your platform: https://github.com/creationix/nvm

Resources