How to migrate an existing application from Node.js Selector to a manual installation

This article describes how to migrate an existing Node.js application from the Node.js Selector in cPanel to a manual Node.js installation.

You may need to do this when migrating from a shared, reseller, or Turbo account to a hosting package that does not include the Node.js Selector in cPanel (such as an unmanaged VPS).

Table of Contents

Migrating an application

In most cases, Node.js applications can be migrated from Node.js Selector with only minor modifications. To do this, follow these steps:

  1. To create the new Node.js application manually, type the following commands:
    mkdir ~/myapp
    cd ~/myapp
    npm init -y
    • For unmanaged hosting packages, you may need to install the Node.js and npm packages first. Consult the documentation for your installed Linux distribution for information about how to do this.
    • You do not have to use the directory name myapp. You can name the directory anything you want.
  2. Log in to cPanel.
    If you do not know how to log in to your cPanel account, please see this article.
  3. Open the Node.js app tool:

    • If you are using the Jupiter theme, on the Tools page, in the Software section, click Setup Node.js App:

      cPanel - Software - Setup Node.js App

    • If you are using the Paper Lantern theme, in the SOFTWARE section, click Setup Node.js App.

      cPanel - Software - Setup Node.js App

  4. Under WEB APPLICATIONS, in the App Root Directory column, note the path for the application's root directory.
  5. Copy the files in the application's root directory to the new application location that you created in step 1 (in our example, this is ~/myapp).
  6. Modify the application files for the new application environment as follows:

    • Port number: Applications created by the Node.js Selector obtain port numbers dynamically. For a manual installation, you probably want to assign a specific port number to the application. The exact procedure to do this depends on the code in your application. For example, the following Express Node.js code demonstrates how to use a hard-coded port number of 3000:
      const express = require('express')
      const app = express()
      const port = 3000
      app.get('/myapp', (req, res) => res.send('Hello World!'))
      app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))
    • Routes: You may have to modify the routes in your application code. This is because applications created by the Node.js Selector use the value specified in the Application URL text box to create the root path. For example, if the Application URL text box in Node.js Selector is set to myapp, then the root path for the application is not “/” but “/myapp”. However, for Node.js applications created outside of the Node.js Selector environment, “/” is typically the root path.
  7. Start the application in Node.js and confirm everything is working correctly.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.