安装

下载并安装 node 和 npm

选择 CLI 版本:

描述

¥Description

要在公共 npm 注册表中发布和安装包,你必须使用 Node 版本管理器或 Node 安装程序安装 Node.js 和 npm 命令行接口。我们强烈建议使用 Node 版本管理器来安装 Node.js 和 npm。我们不建议使用 Node 安装程序,因为 Node 安装过程会将 npm 安装在具有本地权限的目录中,并且在全局运行 npm 包时可能会导致权限错误。

¥To publish and install packages to and from the public npm registry, you must install Node.js and the npm command line interface using either a Node version manager or a Node installer. We strongly recommend using a Node version manager to install Node.js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.

概述

¥Overview

检查 npm 和 Node.js 版本

¥Checking your version of npm and Node.js

要查看你是否已经安装了 Node.js 和 npm 并检查安装的版本,请运行以下命令:

¥To see if you already have Node.js and npm installed and check the installed version, run the following commands:

node -v
npm -v

使用 Node 版本管理器安装 Node.js 和 npm

¥Using a Node version manager to install Node.js and npm

Node 版本管理器允许你在系统上安装和切换多个版本的 Node.js 和 npm,以便你可以在多个版本的 npm 上测试你的应用,以确保它们适用于不同版本的用户。你可以 在 GitHub 上搜索它们

¥Node version managers allow you to install and switch between multiple versions of Node.js and npm on your system so you can test your applications on multiple versions of npm to ensure they work for users on different versions. You can search for them on GitHub.

使用 Node 安装程序安装 Node.js 和 npm

¥Using a Node installer to install Node.js and npm

如果你无法使用 Node 版本管理器,你可以使用 Node 安装程序在你的系统上安装 Node.js 和 npm。

¥If you are unable to use a Node version manager, you can use a Node installer to install both Node.js and npm on your system.

OS X 或 Windows Node 安装程序

¥OS X or Windows Node installers

如果你使用的是 OS X 或 Windows,请使用 Node.js 下载页面 中的安装程序之一。请务必安装标记为 LTS 的版本。其他版本尚未使用 npm 进行测试。

¥If you're using OS X or Windows, use one of the installers from the Node.js download page. Be sure to install the version labeled LTS. Other versions have not yet been tested with npm.

Linux 或其他操作系统 Node 安装程序

¥Linux or other operating systems Node installers

如果你使用的是 Linux 或其他操作系统,请使用以下安装程序之一:

¥If you're using Linux or another operating system, use one of the following installers:

或者参见 此页面 以许多 Linux 开发者喜欢的方式为 Linux 安装 npm。

¥Or see this page to install npm for Linux in the way many Linux developers prefer.

不太常见的操作系统

¥Less-common operating systems

有关在各种操作系统上安装 Node.js 的更多信息,请参阅 此页面

¥For more information on installing Node.js on a variety of operating systems, see this page.

npm 中文网 - 粤ICP备13048890号