Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there a 'js' command on Node JS for Linux?

I've installed on a XUbuntu 13.10 the software Node.js through package manager:

xxx@xxx:/$ sudo apt-get install nodejs

All seems good but along with nodejs executable I've found a js executable.

Both, if called with -v option, show v0.10.15 and I've successfully used both of them as a Javascript interpreter.

My question is: is there any difference between nodejs command and js command? Is js just an alias for the nodejs command?

like image 394
Vincenzo Maggio Avatar asked Aug 25 '26 21:08

Vincenzo Maggio


1 Answers

It has to do with /etc/alternatives, the Ubuntu/Debian alternatives mechanism.

  • /usr/bin/js — is a link to
  • /etc/alternatives/js — is a link to
  • /usr/bin/node

Thus if you've got /usr/bin in your PATH, running js is effectively exactly the same as running node (except that two symlinks have to be traversed, which is not a significant cost). Using js in scripts (for example) would allow the system to be configured to use an alternative to the installed Node version — maybe a different version, or a version built with some experimental feature.

You can read more about it in the update-alternatives man page.

like image 90
Pointy Avatar answered Aug 28 '26 12:08

Pointy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!