39
loading...
This website collects cookies to deliver better user experience
Node.js
is a JavaScript runtime built on Chrome's V8 engine that helps to build scalable applications. As a web developer, you may find Node.js as omnipresent irrespective of client-side or server-side development. It provides and supports the NPM(Node Package Manager) environment that is widely used today.Ubuntu
is an open-source operating system on Linux. It is available for the hobbyist, enterprises, desktops, and the cloud. In this article, we will learn to install, manage Node.js on the Ubuntu operating system so that you can quickly run a web application.Please feel free to skip this section if you are already aware or want to directly get to the installation commands.
LTS
and Current
.Long Term Support
. The releases with this version focused on stability and security. If you plan to use Node.js in an enterprise app, you may opt for an LTS version.Current
version is the Node.js release under active development for an upcoming major release. There is also a Nightly
build available every 24-hours when there are changes.Ubuntu 20.04 LTS
that releases every two years in April. Here also, the LTS releases are suitable for enterprises. You may find this image helpful in understanding Ubuntu's release cycles, versioning.PPA
is the short form of Personal Package Archive
. It allows you to upload Ubuntu source packages to be published as an apt
repository. The apt
is Advanced Package Tool that helps to install, remove apps on Ubuntu.sudo apt-get install curl
curl
. Now use the following command to get the Node.js PPA and add it to the local system.curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
s
and L
switch of curl shows an error if the request fails and follows the HTTP redirects. Now, we can use the apt tool to install Node.js.sudo apt-get install nodejs
node -v
npm
utility. Please check its version as well to confirm the availability.npm -v
curl
utility to download and use the script. Run the following command from your Ubuntu terminal,curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
master
with the version number in the above URL. For example,curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.profile
nvm install node
nvm install 16.0.0
nvm ls
nvm ls-remote
nvm use 10.0.0
nvm which 4.6
server.js
.var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Awesome People\n');
}).listen(3000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3000/');
nvm exec 10.10.1 server.js
yarn
tool multiple ways on a Ubuntu OS. You can install it using PPA, script, or just by using the npm
command. As we have installed npm
already, let's use the same to install yarn globally. npm install -g yarn
sudo apt-get remove nodejs
sudo apt-get remove npm
sudo apt-get update
nvm uninstall 12.7.0
.nvm
directory. If so, please remove manually,cd ~/.nvm/versions/node
sudo rm -rf v12.7.0/