If you are familiar with using SSH, you may find the command line interface faster and easier than using the cPanel install interface.

To set up a node.js application from the command line, follow these steps:

1) Connect to your account via SSH.
2) Create the Node.js application with the following command:

cloudlinux-selector create --json --interpreter nodejs --version 11 --app-root app --domain example.com --app-uri app

Once you are inside your account’s home directory, change to the application directory

cd ~/app

Open your preferred text editor and create the package.json file. In our example, we’ll use the vi editor.

vi package.json

press i to change to insert mode and paste the following text into the editor.

{
"name": "app",
"version": "1.0.0",
"description": "My App",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

Press Escape key followed by : to enter command mode.
Press x followed by Enter key to save and exit the vi editor.

4) Install npm by entering the following command.

cloudlinux-selector install-modules --json --interpreter nodejs --user example --app-root app

To install packages with NPM and do other command-line tasks related to the application, log in via SSH
and enter the virtual environment for the application using the command

source /home/example/nodevenv/app/11/bin/activate && cd /home/example/app
Was this answer helpful? 3 Users Found This Useful (3 Votes)