CityHost.UA
Help and support

How to install Node.js + npm on hosting?

Node.js is a JavaScript code execution environment that is built on top of Chrome V8 JavaScript, which allows you to translate JavaScript calls to machine code. Node.js is primarily designed for creating server-side applications in JavaScript.

NPM , short for Node Package Manager, is the standard package manager for Node.js and the world's largest software repository for publishing open source Node.js packages.

To install Node.js and npm, you need to connect via SSH to the hosting server.

You can find connection instructions in the [WORKING WITH SSH] section.

Installing Node.js on hosting is possible through NVM (Node Version Manager).

1. After connecting to the server, directly in the home directory of your hosting account, run the following command to install NVM:

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

The script will copy the NVM repository from Github to "$HOME/.nvm" and add the path to the script to the local Bash profile of the hosting account.

The text that will be displayed on the screen after executing the previous command will inform you that you need to either reconnect via SSH or run commands that will add the path to NVM to the current session.

 export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Ця команда завантажить nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # Ця завантажить nvm bash_completion

To check the correctness of the NVM installation and the installed version, enter the command:

 nvm --version

The team must provide an answer of the following form:

 0.35.3

2. Now that NVM is installed, you can install the latest available version of Node.js. To do this, enter the command:

 nvm install node

The correctness of the installation and the version of Node.js can be checked with the command:

 node --version

Example of command output:

 v15.5.1

3. To install npm, use the command:

 curl https://npmjs.org/install.sh | bash

You can check the correctness of the installation and find out the version of the package manager with the command:

 npm --version

Project creation begins with initialization by the command:

 npm init