Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs, Npm, node. Package difference?

Recently working with NodeJS ect. I installed quite different packages, for different tutorials + projects. I finally ended up with this kind of configuration:

louis@louis:~$ node -v
v5.10.0
louis@louis:~$ nodejs -v
v6.2.1
louis@louis:~$ npm -v
3.8.3

Can you explain the difference between these?

like image 691
Louis Lecocq Avatar asked Feb 07 '23 20:02

Louis Lecocq


1 Answers

Your situation

Seems you have two different versions of nodejs installed, possibly one was installed from sources and one from package manager like apt.


louis@louis:~$ node -v
v5.10.0

This returns older version of nodejs that you installed, I recommend you to remove it.


louis@louis:~$ nodejs -v
v6.2.1

This returns the current version of nodejs installed, possibly you installed it using package manager, I remember in Ubuntu it comes by nodejs executable name.

I suggest you to create link like this

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

so it will be available using node command also.

nodejs vs node on ubuntu 12.04


louis@louis:~$ npm -v
3.8.3

This is just version of your npm program and has nothing to do with nodejs version.

Better solution

Uninstall all versions that you have and install node using nvm to switch between old/new versions easily

To install or update nvm, you can use the install script using cURL:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash

or Wget:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash

Usage

To download, compile, and install the latest v5.0.x release of node, do this:

nvm install 5.0

And then in any new shell just use the installed version:

nvm use 5.0

https://github.com/creationix/nvm#install-script

like image 71
gevorg Avatar answered Feb 10 '23 23:02

gevorg