Welcome to our comprehensive guide on installing Node.js on LinuxMint. Node.js is a popular JavaScript runtime built on Chrome’s V8 JavaScript engine, enabling developers to build scalable network applications. This article is tailored for both beginners and experienced developers looking to set up Node.js on their LinuxMint environment.

Advertisement

We will explore two primary methods to install Node.js: first, by using the official PPA (Personal Package Archive), and second, through the Node Version Manager (NVM), a versatile tool for managing multiple Node.js versions. Additionally, we will walk you through a practical example of creating a demo web server using Node.js, illustrating the power and simplicity of Node.js in web development. Whether you are setting up a development environment or preparing for a production deployment, this guide will ensure a smooth installation process.

How to Install Node.js on LinuxMint

This quick how-to guide provides you with two methods to install Node.js & NPM on Linux Mint 21, 20, and 19 Linux systems.

Method 1 – Installing Node.js with Official PPA

First of all, you need to node.js PPA in our system provides by Nodejs official website. We also need to install the python-software-properties package if not installed already. You can choose either to install the latest Node.js version or the LTS version.

For Latest Release

sudo apt-get install curl python-software-properties software-properties-common 
curl -sL https://deb.nodesource.com/setup_21.x | sudo bash - 

For LTS Release

sudo apt-get install curl python-software-properties software-properties-common 
curl -sL https://deb.nodesource.com/setup_20.x | sudo bash - 

For this tutorial, I have added the latest release Apt repository on my Linux Mint system. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.

sudo apt-get install nodejs 

Method 2 – Installing Node.js with NVM

NVM provides a shell script for the installation on the Linux system. So, execute the installer script with the below commands. This will install the nvm command on your system.

sudo apt install curl 
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 

Now, load the nvm environment in the current shell with the below command.

source ~/.profile 

NVM is successfully installed on your system. Now you can install any node.js version with the help of NVM.

nvm install 16.14 

You can run the above command with different 2 versions to install any number of Node.js on your Linux Mint systems. For example, you can use nvm install 17 or nvm install 12.18, etc.

The systems have multiple node.js versions installed, can use the below command to set any installed node.js version as an active version.

nvm use 16.14 

You can find detailed instruction’s about the node.js installation in our previous tutorials. Find more details about Node.js installation via NVM.

How to Check Default Node.js Version

After completing the installation process of node.js, Let’s check and verify the installed version. You can find more details about the current version on node.js official website.

node -v  

v19.2.0

Also, check the version of NPM.

npm -v  

8.19.3

Step 4: Create A Demo Web Server (Optional)

This is an optional step. If you want to test your node.js install. Let’s create a web server with “Hello World!” text. Create a file http_server.js

nano http_server.js 

and add the following content


var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(3000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3000/');

Now start the web server using the command.

node http_server.js 

Server running at http://127.0.0.1:3000/

The web server has been started on port 3000. Now access http://127.0.0.1:3000/ URL in the browser.

Conclusion

In this article, we have successfully navigated the installation of Node.js on LinuxMint using two reliable methods: the official PPA and NVM. Both methods offer flexibility and ease, catering to different needs and preferences of developers. Using the official PPA provides a straightforward approach to installing Node.js, while NVM offers a more flexible solution for handling multiple versions of Node.js. Additionally, the demo web server example showcased how quickly and efficiently one can start developing with Node.js, making it an excellent choice for modern web development.

Remember, choosing the right installation method depends on your specific project requirements and development setup. With Node.js installed, you’re now ready to embark on building efficient, scalable, and high-performance web applications on your LinuxMint system. Happy coding!

Share.

23 Comments

  1. For Linux Mint 20, this was what I had to do as a first step:

    sudo apt-get install curl software-properties-common

  2. Bryan Walls on

    When I tried to install on Mint 19.2 using setup_14.x, everything seemed to work. But I ended up with version 8.10.0. Trying to update says, “nodes is already the newest version (8.10.0-dfsg-2ubuntu0.4)”. What’s going on?

    • Bryan Walls on

      Figured out what was going on. I’m on a 32-bit Intel platform, and Node quit supporting 32-bit Linux. Was able to find an unsupported 12 version that’s working.

  3. Thanks… my experience may be unique, I don’t know. But I had to tweak you install script to get this to work.

    Specifically I had to comment out line 191 “exec_cmd ‘apt-get update'”. The reason being that this command produced some errors (three “E:…” output: 2 x “404” and 1 x “Some index files failed to download…”), and this apparently meant that your script didn’t continue. NB am a newb in scripts as well as Linux…

    Without commenting this line out the PPA does not get set up. Perhaps you might look into this and modify accordingly. Perhaps there’s no reason to include the “apt-get update” before you’ve actually installed the PPA?

  4. Marlon Baculio on

    To fix this error:

    # Your distribution, identified as “tina”, is not currently supported, please contact NodeSource …

    1. Put this URL in your browser: https://deb.nodesource.com/setup_10.x
    2. Copy the output script/text from that browser and write it to your own file like ~/setup_10.x
    3. In the middle of that file, look for the check_alt’s for Mint, then insert this line:

    check_alt “Linux Mint” “tina” “Ubuntu” “bionic”

    4. Save file then grant exec permission: chmod +x ~/setup_10.x
    5. Run: sudo ~/setup_10.x
    6. If no errors, proceed with: sudo apt-get install nodejs

    Good luck!

  5. Pablo Orellana on

    Your information have been very useful to me. I would ask you if you have a little project in nodejs where i can see html,css, javascript. Thanks in advance

  6. Thank you very much for this guide. Its spot on and has worked on so many different Linux based machines I have created. Figured it was time to finally say thank you for it!

  7. The python-software-properties package doesn’t appear to be needed or used by Node.js. There’s no reason to install it.

    Your instructions for installing the “latest” version of Node.js are incorrect. That “10” is a version number, but the latest version is 11 (right now).

    The problem here is really with NodeSource. I wish they would create a /setup_latest path on their repository server. For that matter, I wish they would document the node package setup paths somewhere where I could find it instead of guessing that there must be a setup_11.x path because that’s the current version.

Leave A Reply


Exit mobile version