Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
124 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...