
Node.js is a JavaScript platform for general programming that allows users to create network applications quickly. By leveraging JavaScript in both frontend and backend, Node.js makes development more uniform and integrated. Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. runtime for easily building fast, scalable network applications. In this guide, we'll show you how to get started with Node.js on an Ubuntu 18.04 server.
You can add the PPA to your Ubuntu 18.04 LTS systems and install node.js on Linux VPS with a few easy commands. To start the process you should have a non-root user account with sudo privileges set up on your system
Add Node.js PPA from NodeSource
Ubuntu 18.04 contains a version of Node.js in its default repositories that can be used to provide a consistent experience across multiple systems. You can select which version you want to install on the system. Add the following PPA's to your system to install Nodejs on Ubuntu.
To get a more recent version of Node.js you can add the PPA (personal package archive) maintained by NodeSource.
sudo apt-get install curl curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
Or you can use the most recent LTS release available.
sudo apt-get install curl curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
Install the package Version from Ubuntu repositories or from NodeSource PPA
To get this version, you can use the apt package manager. Refresh your local package index by typing:
sudo apt update sudo apt install nodejs
If you also want to install npm, the Node.js package manager. You can do this by typing:
sudo apt install npm This will allow you to install modules and packages to use with Node.js.
After installing node.js verify and check the installed version.
node -v v14.2.0
Check the npm version
npm -v 8.10.7
Create a Demo Test Web Server
If you want to test your node.js install you can create a web server with “Hello World!” text. Create a file server.js
nano test-server.js
and add the following content
test-server.jsvar http = require('http'); http.createServer(function (request, response) { response.writeHead(200, { 'Content-Type': 'text/plain' }); response.end('Hello World from Noden'); }).listen(1333, "127.0.0.1"); console.log('Server running at http://127.0.0.1:3000/');
Now start the Node application using the command.
node test-server.js debugger listening on port 5858 Server running at http://127.0.0.1:1333/
You can also start the application with debugging enabled with the following commands.
node --inspect test-server.js Debugger listening on ws://127.0.0.1:9229/428cf97a-a4b6-3158-134b-c1357c9b24c54 For help, see: https://nodejs.org/en/docs/inspector Server running at http://127.0.0.1:1333/
The web server has been started on port 1333. You can access it from http://127.0.0.1:1333/ URL in browser. Now you will need to configure a front-end server for your app.
Removing Node.js
You can uninstall Node.js using apt, to remove the distro-stable version, you will need to work with the apt utility at the system level.
To remove the distro-stable version, type the following:
sudo apt remove nodejs
This command will remove the package and retain the configuration files. These may be of use to you if you intend to install the package again at a later point. If you don’t want to save the configuration files for later use, then run the following:
sudo apt purge nodejs
This will uninstall the package and remove the configuration files associated with it.
As a final step, you can remove any unused packages that were automatically installed with the removed package:
sudo apt autoremove

Luigi Nori
He has been working on the Internet since 1994 (practically a mummy), specializing in Web technologies makes his customers happy by juggling large scale and high availability applications, php and js frameworks, web design, data exchange, security, e-commerce, database and server administration, ethical hacking. He happily lives with @salvietta150x40, in his (little) free time he tries to tame a little wild dwarf with a passion for stars.
Related Posts
How to use the endsWith method in JavaScript
In this short tutorial, we are going to see what the endsWith method, introduced in JavaScript ES6, is and how it is used with strings in JavaScript. The endsWith method is…
What are javascript symbols and how can they help you?
Symbols are a new primitive value introduced by ES6. Their purpose is to provide us unique identifiers. In this article, we tell you how they work, in which way they…
Callbacks in JavaScript
Callback functions are the same old JavaScript functions. They have no special syntax, as they are simply functions that are passed as an argument to another function. The function that receives…
How to create PDF with JavaScript and jsPDF
Creating dynamic PDF files directly in the browser is possible thanks to the jsPDF JavaScript library. In the last part of this article we have prepared a practical tutorial where I…
How to make your own custom cursor for your website
When I started browsing different and original websites to learn from them, one of the first things that caught my attention was that some of them had their own cursors,…
Node.js and npm: introductory tutorial
In this tutorial we will see how to install and use both Node.js and the npm package manager. In addition, we will also create a small sample application. If you…
How to connect to MySQL with Node.js
Let's see how you can connect to a MySQL database using Node.js, the popular JavaScript runtime environment. Before we start, it is important to note that you must have Node.js installed…
JavaScript Programming Styles: Best Practices
When programming with JavaScript there are certain conventions that you should apply, especially when working in a team environment. In fact, it is common to have meetings to discuss standards…
Difference between arrow and normal functions in JavaScript
In this tutorial we are going to see how arrow functions differ from normal JavaScript functions. We will also see when you should use one and when you should use…
JavaScript Arrow functions: What they are and how to use them
In this article we are going to see what they are and how to use JavaScript Arrow Functions, a new feature introduced with the ES6 standard (ECMAScript 6). What are Arrow…
How to insert an element into an array with JavaScript
In this brief tutorial you will learn how to insert one or more elements into an array with JavaScript. For this we will use the splice function. The splice function will not…
What is the difference between primitives types and objects in JavaScript?
In this short tutorial we are going to look at the differences between primitive types and objects in JavaScript. To start with, we're going to look at what primitive types…