Node.js has become a critical component for building fast, scalable web applications. If you’re using Debian 12 and want to install the latest version of Node.js, such as v20.x, here’s a quick guide to get you started.

Step 1,Update Your System

Before installing Node.js, it’s always a good idea to ensure your system is up-to-date. You can do this by running:

This will ensure you have the latest security patches and updates.

Step 2, Install the Required Dependencies

To install Node.js, we need to install a few prerequisite packages. These will allow Debian to manage new repositories and downloads:

Step 3, Add the NodeSource Repository

Node.js v20.x is not available in the default Debian repositories, so we’ll need to use NodeSource. Run the following command to add the NodeSource repository for Node.js v20.x:

This command downloads and sets up the necessary repository for Node.js.

Step 4, Install Node.js

Now that the NodeSource repository has been added, you can install Node.js v20.x by running:

This command will install both Node.js and npm (Node.js package manager).

Step 5, Verify Installation

Once installed, you can verify the installation of Node.js and npm by checking their versions:

You should see something like:

and for npm:

This means Node.js and npm have been successfully installed on your Debian 12 system.

Step 6, Optional – Install Build Tools

For some Node.js packages, you may need to install additional build tools. You can install them by running:

These tools will allow you to compile native Node.js modules.

Step 7, Managing Node.js Versions (Optional)

If you ever want to manage multiple versions of Node.js, you can use nvm (Node Version Manager). However, if you installed Node.js using NodeSource, you are already using the latest stable version.

To install nvm, run the following:

You can now install and switch between different Node.js versions easily with nvm.

By following these steps, you should have Node.js v20.x up and running on your Debian 12 system. Node.js brings a powerful environment for building scalable network applications, and now you’re all set to start developing!

Happy coding!

Leave A Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.