110

I've installed node.js in my machine (linux mint 15), when I run node example.js, it says:

The program 'node' can be found in the following packages:
 * node
 * nodejs-legacy
Try: sudo apt-get install <selected package>

So what are the differences between node and nodejs? I had both node.js and node installed previously, but when I run node example.js, the web server doesn't start at all. So I deleted node and kept node.js.

RBT
  • 24,161
  • 21
  • 159
  • 240
Blake
  • 7,367
  • 19
  • 54
  • 80
  • Related post - [What is the difference between node.js runtime and npm package manager options while installing node.JS?](https://stackoverflow.com/q/41675848/465053) – RBT Mar 28 '20 at 00:44

3 Answers3

160

The package node is not related to node.js.

nodejs is what you want, however it is arguably better to have the command be called node for compatibility with scripts that use #!/usr/bin/env node.

You can either just create a symlink in your path:

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

Or you could install nvm and then use it to install the latest version of node.js:

nvm install stable

I prefer the nvm method, as it allows you to sudo apt-get remove nodejs, and then manage which version of node you're using yourself. You can also have multiple versions of node.js installed and use nvm use <version> to easily switch between them.

I also like to add a line to the bottom my .bashrc like: nvm use stable > /dev/null. That will automatically use the latest version you have installed.

To update your node version to the latest stable: nvm install stable. Every time you do this you will need to install any npm packages that you had installed globally if you want to continue using them.

To switch to an old version just run nvm use <version>, or, if you don't have the old version installed already: nvm install <version>.

Hugolpz
  • 17,296
  • 26
  • 100
  • 187
Paul
  • 139,544
  • 27
  • 275
  • 264
  • 28
    actually, the `nodejs-legacy` package just contains the symlink (see also https://lists.debian.org/debian-devel-announce/2012/07/msg00002.html). – someonr Jan 20 '15 at 20:10
  • 1
    Very helpful and handy is **nvm** package. – Akshay Pratap Singh Oct 17 '15 at 19:26
  • In JS world, people keep calling node; in that case does it refer to node.js ? – vikramvi Jul 19 '19 at 11:39
  • 1
    @vikramvi Yes, when you here people talking about node they are probably refering to node.js; either that or DOM nodes in a browser – Paul Jul 19 '19 at 12:51
  • The decision to name node and nodejs so similarly has to be the dumbest naming decision in computer history. One or both should be renamed. – niico Aug 11 '22 at 15:10
40

This answer is just to tell you the difference between node and nodejs packages on Debian OS.

node

nodejs

  • Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
  • Package details link:
Raghav Dinesh
  • 591
  • 5
  • 12
  • 13
    The answer that explains the _actual_ difference between `node` and `nodejs`. – Bono Jun 29 '17 at 11:40
  • 2
    How will I understand the difference between the two in layman's language? – mansoor.khan Mar 27 '18 at 08:50
  • 4
    @steady_daddy The two packages are unrelated to each other, so the simple answer is that the two are unrelated. nodejs is a modern javascript-oriented server framework typically used to provide various services and realtime applications, while node is an older framework for transmitting data packets over amateur radio. Most installations symlink the shell command "node" to the binary "nodejs" and this is usually safe to do since hardly anyone using nodejs will encounter conflicts with "node". – EddieOffermann Jan 17 '19 at 06:29
  • man node and man nodejs Yield the same exact manual pages on my WSL Debian Hmm ..... No mention of amateur radio. They both talk about node.js. – Craig Wilcox Jul 27 '23 at 23:26
4

There is a simple answer.

  1. Node.JS is the script/code
  2. Node compiles and runs the Node.JS
Rashid Iqbal
  • 1,123
  • 13
  • 13