如何安装 Node.js

¥How to install Node.js

Node.js 可以通过不同的方式安装。这篇文章重点介绍了最常见和最方便的代码。所有主要平台的官方软件包均可在 nodejs.cn/download/ 获得。

¥Node.js can be installed in different ways. This post highlights the most common and convenient ones. Official packages for all the major platforms are available at nodejs.cn/download/.

一种非常方便的安装 Node.js 的方法是通过包管理器。在这种情况下,每个操作系统都有自己的。nodejs.cn/download/package-manager/ 中列出了适用于 macOS、Linux 和 Windows 的其他软件包管理器。

¥One very convenient way to install Node.js is through a package manager. In this case, every operating system has its own. Other package managers for macOS, Linux, and Windows are listed in nodejs.cn/download/package-manager/.

nvm 是一种流行的运行 Node.js 的方式。它允许你轻松切换 Node.js 版本,并安装新版本以尝试在出现故障时轻松回滚。使用旧版本的 Node.js 测试代码也非常有用。

¥nvm is a popular way to run Node.js. It allows you to easily switch the Node.js version, and install new versions to try and easily rollback if something breaks. It is also very useful to test your code with old Node.js versions.

有关此选项的更多信息,请参阅 https://github.com/nvm-sh/nvm

¥See https://github.com/nvm-sh/nvm for more information about this option.

无论如何,安装 Node.js 后,你都可以在命令行中访问 node 可执行程序。

¥In any case, when Node.js is installed you'll have access to the node executable program in the command line.