This chapter/section is part of a future book on full-stack MERN (MongoDB, Express, React & Node) development. For the full table of contents with links to all completed chapters see Full-stack Mern Development.
Installing NodeJS on Ubuntu
October 14, 2019
If your a JavaScript developer you are familiar with Node and and already know how to install it on a Mac or Windows machine. If you are new to Ubuntu, here is the quick and easy way to install NodeJS.
Make sure you have cURL installed
cURL is a command-line tool for getting or sending data including files using URL syntax. (Wikipedia).
If you are not sure if you have cURL installed you can check with this command:
curl --version
If cURL is installed you will get a response like this:
curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.1 zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp/2.3
Release-Date: 2018-01-24
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
If cURL is not installed use these commands to install it:
sudo apt-get update
sudo apt-get install curl
Installing Node
This process will download a setup script to the current directory. Change directory to a suitable location such as Downloads
cd Downloads
Download the node setup script.
curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh
The next step is to execute the script just downloaded. Note that the script does not install Node. It only sets up you machine so that Node can be installed.
sudo bash nodesource_setup.sh
Now check your Node version to confirm installation.
sudo apt-get install -y nodejs
Check that Node is installed.
nodejs -v
Installing Node also installed npm. Check the npm version with this command.
npm -v
That’s it. NodeJS & npm are now installed and ready to use.
References
- cURL: Wikipedia
- NodeSource Node.js Binary Distributions
Technical blog by klequis