how to install node.js and NVM on debian

0
(0)

NVM Installation
Instead of installing Node.js through apt, you can use a tool called nvm, whose name stands for “Node.js Version Manager”. Instead of operating at the operating system level, nvm operates at the independent directory level inside the home directory. This means that you can install different self-contained versions of Node.js, and this will not affect the system as a whole.

Controlling the environment with nvm allows you to access the latest versions of Node.js, while maintaining previous versions and managing them. This utility is different from apt, and the versions of Node.js that it manages are different from those managed by apt.

To download the nvm installation script from the project page on GitHub, you can use curl. Please note that the version number may differ from the one highlighted here:

$ curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh -o install_nvm.sh
$ bash install_nvm.sh

The software will be installed in a subdirectory of the home directory at ~ / .nvm. Also, lines necessary for using the file will be added to the ~ / .profile file.

To access the nvm function, you will need to log out and log back in or refer to the ~ / .profile file so that the current session is aware of the changes:

$ source ~/.profile

After installing nvm, you can install isolated versions of Node.js. For information on the available versions of Node.js, type:

$ nvm ls-remote
Output
...
         v8.11.1   (Latest LTS: Carbon)
         v9.0.0
         v9.1.0
         v9.2.0
         v9.2.1
         v9.3.0
         v9.4.0
         v9.5.0
         v9.6.0
         v9.6.1
         v9.7.0
         v9.7.1
         v9.8.0
         v9.9.0
        v9.10.0
        v9.10.1
        v9.11.0
        v9.11.1
        v10.0.0  
        v10.1.0
        v10.2.0
        v10.2.1
        v10.3.0
        v10.4.0
        v10.4.1
        v10.5.0
        v10.6.0
        v10.7.0
        v10.8.0
        v10.9.0

As you can see, at the time of writing, the current version of LTS is v8.11.1. You can install it by entering the following command:

$ nvm install 8.11.1

After installing Node.js using nvm, the executable is named node. The version number used by the shell can be viewed using the following command:

$ node -v

Each version of Node.js will track its own packages and have access to npm to manage them.

1,217

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Scroll to Top