终端中的 node 与 nodejs 命令有什么区别? [英] What is the difference between node vs nodejs command in terminal?
问题描述
我从 nodejs.org 上给出的 tar 文件中解压了 node.js,但是当我尝试通过 node 命令执行我的 js 程序时没有任何反应,但另一方面 nodejs 命令运行执行该文件.
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.
所以我的问题是 node 命令和 nodejs 命令之间的区别是什么,因为它会影响我的程序,因为我不是从源代码构建的.我这就是造成这种差异的原因.
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.
推荐答案
这在很大程度上取决于许多因素.主要取决于你的 shell 中的 node
和 nodejs
实际上是什么.您可以使用 type node
/type nodejs
和/或 which node
/which nodejs
(或者也许 <代码>在哪里代码>).这也取决于操作系统和外壳.
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.
我的猜测是 which -a node
将产生 /usr/sbin/node
哪个 not nodejs 可执行文件,因此为什么它不执行您的节点代码.在我的系统上,它是:
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
即node
只是到 nodejs
的符号链接,它是可执行文件.
i.e. node
is just a symbolic link to nodejs
, which is the executable.
您也可以自己创建此别名,以便它覆盖适合您的任何 node
.
You can also create this alias yourself so that it overrides whatever node
is for you.
这篇关于终端中的 node 与 nodejs 命令有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!