Skip to content

Instantly share code, notes, and snippets.

@optimistanoop
Last active February 24, 2021 11:32
Show Gist options
  • Save optimistanoop/e16a1e5c958bd9efae2683ef9f25c549 to your computer and use it in GitHub Desktop.
Save optimistanoop/e16a1e5c958bd9efae2683ef9f25c549 to your computer and use it in GitHub Desktop.
install nodejs

Installing Node.js and npm from NodeSource

NodeSource is a company focused on providing enterprise-grade Node support. It maintains an APT repository containing multiple Node.js versions. Use this repository if your application requires a specific version of Node.js.

At the time of writing, NodeSource repository provides the following versions:

v14.x - The latest stable version. v13.x v12.x - The latest LTS version. v10.x - The previous LTS version. We’ll install Node.js version 14.x:

Run the following command as a user with sudo privileges to download and execute the NodeSource installation script:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

The script will add the NodeSource signing key to your system, create an apt repository file, install all necessary packages, and refresh the apt cache.

If you need another Node.js version, for example 12.x, change the setup_14.x with setup_12.x.

Once the NodeSource repository is enabled, install Node.js and npm:

sudo apt install nodejs

The nodejs package contains both the node and npm binaries.

Verify that the Node.js and npm were successfully installed by printing their versions:

node --version

v14.2.0

npm --version

6.14.4

To be able to compile native addons from npm you’ll need to install the development tools:

sudo apt install build-essential

thanks to https://linuxize.com/post/how-to-install-node-js-on-ubuntu-20-04/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment