如何在Ubuntu 20.04上安装Node.js

介绍 (Introduction)

Node.js is a JavaScript runtime for server-side programming. It allows developers to create scalable backend functionality using JavaScript, a language many are already familiar with from browser-based web development.

Node.js是用于服务器端编程JavaScript运行时。 它允许开发人员使用JavaScript创建可扩展的后端功能,JavaScript是许多基于浏览器的Web开发已经熟悉的语言。

In this guide, we will show you three different ways of getting Node.js installed on an Ubuntu 20.04 server:

在本指南中,我们将向您展示在Ubuntu 20.04服务器上安装Node.js的三种不同方式:

  • using apt to install the nodejs package from Ubuntu’s default software repository

    使用apt从Ubuntu的默认软件存储库安装nodejs软件包

  • using apt with an alternate PPA software repository to install specific versions of the nodejs package

    结合使用apt和其他PPA软件存储库来安装nodejs软件包的特定版本

  • installing nvm, the Node Version Manager, and using it to install and manage multiple versions of Node.js

    安装nvm ,节点版本管理器,并使用它来安装和管理Node.js的多个版本

For many users, using apt with the default repo will be sufficient. If you need specific newer (or legacy) versions of Node, you should use the PPA repository. If you are actively developing Node applications and need to switch between node versions frequently, choose the nvm method.

对于许多用户而言,将apt与默认存储库配合使用就足够了。 如果需要特定的较新(或旧版)的Node版本,则应使用PPA存储库。 如果您正在积极开发Node应用程序,并且需要经常在node版本之间切换,请选择nvm方法。

先决条件 (Prerequisites)

This guide assumes that you are using Ubuntu 20.04. Before you begin, you should have a non-root user account with sudo privileges set up on your system. You can learn how to do this by following the initial server setup tutorial for Ubuntu 20.04.

本指南假定您正在使用Ubuntu 20.04。 在开始之前,您应该在系统上设置具有sudo特权的非root用户帐户。 您可以通过遵循Ubuntu 20.04初始服务器设置教程来学习如何执行此操作。

选项1-从默认存储库安装带有Apt的Node.js (Option 1 — Installing Node.js with Apt from the Default Repositories)

Ubuntu 20.04 contains a version of Node.js in its default repositories that can be used to provide a consistent experience across multiple systems. At the time of writing, the version in the repositories is 10.19. This will not be the latest version, but it should be stable and sufficient for quick experimentation with the language.

Ubuntu 20.04在其默认存储库中包含一个版本的Node.js,可用于在多个系统之间提供一致的体验。 在撰写本文时,存储库中的版本为10.19。 这不是最新版本,但应该稳定并且足以快速试用该语言。

To get this version, you can use the apt package manager. Refresh your local package index first by typing:

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值