Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between node vs nodejs command in terminal?

I have untarred node.js from the tar file given on nodejs.org, but when i try executing my js program through node command nothing happens, but on the other hand nodejs command runs executes the file.

So my question is what's the difference between node command and nodejs command as and will it effect my programs as i didn't build from the source code. And i of that is the reason of this discrepancy.

like image 397
Aditeya Pandey Avatar asked Mar 17 '14 15:03

Aditeya Pandey


People also ask

What is the different between node and NodeJs?

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.

What is node in terminal?

Terminal node may mean: Leaf node, a node of a tree data structure that has no child nodes. Lymph node, a terminal lymph node in the lymphatic system.

What is node command?

It is a computer environment the same as command prompt and an easy way to test simple Node. js/JavaScript code and allows to execute multiple javascript codes. we can simply run REPL on the command prompt using node command on the command prompt. Syntax: node.

What is difference between NodeJs and npm?

Node. js or Node is an open-source, cross-platform, JavaScript runtime environment(JSRE) that executes JavaScript code outside of a web browser. npm is a package manager(like Nuget package manager in . NET -Microsoft ) for the JavaScript programming language.


2 Answers

This is highly dependent on many factors. Mainly, it depends on what node and nodejs in your shell actually are. You can check this using type node / type nodejs and/or which node / which nodejs (or perhaps whereis). This also depends on the OS and the shell.

My guess is that which -a node will yield /usr/sbin/node which is not the nodejs executable and thus why it does not execute your node code. On my system, it is:

/usr/bin/node -> /etc/alternatives/node -> /usr/bin/nodejs 

i.e. node is just a symbolic link to nodejs, which is the executable.

You can also create this alias yourself so that it overrides whatever node is for you.

like image 105
Explosion Pills Avatar answered Sep 22 '22 21:09

Explosion Pills


Some of these answers were difficult to understand for me, so I'm going to write the answer that would've helped me.

node is something like a radio telemetry solving program, they just happened to snag the name node first. nodejs is what you're after. So make sure you:

apt-get install nodejs 

then, to fix the lame naming issue, create a symlink. A symbolic link between node and nodejs.

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

The first part is the original file placement, and then where it should link to. You could also create an alias in your bash profile, which is also pretty easy.

like image 24
Eric Prostko Avatar answered Sep 22 '22 21:09

Eric Prostko