Open In App

How to Install and Manage Node using NVM on Godaddy Server ?

Last Updated : 20 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Managing multiple versions of Node.js on your server can be quite a task, especially if you're developing or maintaining applications that require different versions. Node Version Manager (NVM) simplifies this process by allowing you to install and switch between different versions of Node.js easily. This article will guide you through installing and managing Node.js using NVM on a GoDaddy server.

Introduction to NVM

Node Version Manager (NVM) is a bash script that allows you to manage multiple Node.js versions on a single machine. It lets you install, switch, and use different versions of Node.js without conflicts.

Why Use NVM on GoDaddy?

GoDaddy VPS is a shared server that provides computational services, databases, storage space, automated weekly backups, and 99% uptime. GoDaddy Server is a cloud-based hosting platform consisting of virtual and dedicated servers. 

  • Multiple Versions: Easily switch between different Node.js versions for different projects.
  • Isolation: Each version of Node.js can have its own set of global npm packages, avoiding version conflicts.
  • Flexibility: Quickly test your application on various Node.js versions.

The premium service includes weekly backups, 99% uptime, 24x7 Customer Support, a free encrypted SSL certificate, unlimited bandwidth, and SSD storage. For regular users, the latest generation is VPS Gen 4, which uses QEMU as the hypervisor to perform hardware virtualization. It offers a cheaper alternative to Amazon Web Service and Google Cloud Platform. 

In this article, we will discuss how to install the latest version of Node and NPM on GoDaddy VPS Gen 4 (Ubuntu).

Installing NVM

Step 1:  Open your terminal by searching it in the application Menu and ssh into the Godaddy server.

$ ssh [username]@[ip]

Step 2: Update and upgrade the server by running.

sudo apt update -y
sudo apt upgrade -y

Step 3: Install the latest version of nvm by executing the required bash script.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

Step 4: Now, open the .bashrc file and append the path variables to the end of the file

nano ~/.bashrc

Step 5: Now, set the path for the NVM home directory by pasting the following at the end of the file.

export NVM_DIR="$HOME/.nvm"

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

Step 6: Commit the changes by reloading the .bashrc file.

source ~/.bashrc

Step 7: Verify if nvm has been installed on the server successfully

nvm --version

Installing Node and NPM

Step 1: Install the latest version of node and npm by running

nvm install node

Step 2: Verify the installation by checking the build version of node and npm

$ node --version
$ npm --version

Managing Node versions

Step 1: To install an older version of the node.

nvm install [version]

Step 2: To use the newly installed version.

nvm use [version]

Step 3: Set a specific version as default.

nvm alias default [version]

Step 4: Remove an existing version by running.

nvm uninstall [version]

Using Node JS

To test the node compiler, create a Javascript program that outputs 'Hello GFG' using node. Now compile the JS file using node.

node filename.js

Conclusion

NVM is an invaluable tool for Node.js developers, providing the flexibility to install, manage, and switch between multiple versions of Node.js seamlessly. On a GoDaddy server, NVM simplifies the process of maintaining your Node.js environment, ensuring you can work with the right versions for your projects. By following this guide, you can effectively manage Node.js installations on your GoDaddy server, enhancing your development workflow and ensuring compatibility across different applications.


Next Article

Similar Reads