node.js 和 node 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20057790/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:18:07  来源:igfitidea点击:

What are the differences between node.js and node?

node.jsapt-getaptlinux-mint

提问by Blake

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

我已经在我的机器(linux mint 15)中安装了 node.js,当我运行时node example.js,它说:

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.

那么node和nodejs有什么区别呢?我之前安装了 node.js 和 node,但是当我运行时node example.js,Web 服务器根本没有启动。所以我删除了节点并保留了 node.js。

回答by Paul

The package node is not related to node.js.

包节点与 node.js 无关。

nodejsis 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.

nodejs是您想要的,但是为了与使用#!/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 nvmand then use it to install the latest version of node.js:

或者您可以安装 nvm,然后使用它来安装最新版本的 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 useto easily switch between them.

我更喜欢 nvm 方法,因为它允许您sudo apt-get remove nodejs管理自己使用的节点版本。您还可以安装多个版本的 node.js 并使用nvm use它们轻松切换。

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

我也喜欢在底部添加一行我.bashrc喜欢的:nvm use stable > /dev/null。这将自动使用您安装的最新版本。

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.

要更新您的节点版本到最新的稳定:nvm install stable。每次执行此操作时,如果您想继续使用它们,您都需要安装已全局安装的任何 npm 包。

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>.

要切换到旧版本,只需运行nvm use <version>,或者,如果您尚未安装旧版本:nvm install <version>.

回答by Raghav Dinesh

This answer is just to tell you the difference between nodeand nodejspackages on Debian OS.

这个答案只是告诉您Debian 操作系统上的nodenodejs软件包之间的区别。

node

node

nodejs

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/Omodel that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
  • Package details link:
  • Node.js 是一个基于 Chrome 的 JavaScript 运行时构建的平台,用于轻松构建快速、可扩展的网络应用程序。Node.js 使用事件驱动的非阻塞I/O模型,使其轻量级和高效,非常适合跨分布式设备运行的数据密集型实时应用程序。
  • 套餐详情链接: