bash | node webdriver support | install notebooks | Search

To install Node.js version 9.x on a Linux system, execute the installation script with the command curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - and then update the package index with sudo apt-get update -qqy.

Run example

npm run import -- "install node"

install node

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash - \
    && sudo apt-get update -qqy \
    && sudo apt-get -qqy install nodejs build-essential

What the code could have been:

bash
#!/bin/bash

# Install Node.js 9.x via nodesource repository
# https://github.com/nodesource/distributions/blob/master/README.md#installing-nodejs-and-npm-from-source-using-compiled-binary-tarball-or-from-source-with-gcc

# Define the installation script URL
NODE_SETUP_URL='https://deb.nodesource.com/setup_9.x'

# Download the installation script and pass it to bash for execution
curl -sfL "$NODE_SETUP_URL" | sudo -E bash -

# Update the package list
sudo apt-get update -qqy

# Install Node.js and build-essential
sudo apt-get -qqy install nodejs build-essential

# TODO: Consider using a more robust error handling mechanism, e.g., trap and set -e
# TODO: Refactor code to use functions for better modularity and reusability

Code Breakdown

Download and Execute Installation Script

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

Update Package Index

sudo apt-get update -qqy

Install Node.js and Build Essential Packages

sudo apt-get -qqy install nodejs build-essential