Updating Node.js Apps (TypeScript / .ts files) in cPanel with CloudLinux Print

  • 0

When hosting a Node.js application on a cPanel server with CloudLinux, customers often edit .ts (TypeScript) files directly (e.g., Controllers/HomeControllers.ts).
However, changes will not appear live immediately. This is because production apps run from the compiled JavaScript in the dist/ folder, not the raw .ts files.

 

To make changes take effect, you must rebuild the app and restart it.


Steps to Apply Code Changes

Option 1: Using cPanel GUI (Recommended for Customers)

  1. Log in to cPanel.

  2. Go to Setup Node.js App.

  3. Locate your app (example: api.neobeststar.com).

  4. If you edited any .ts files:

    • Click Run NPM Install (this ensures dependencies are available).

    • Click Run Script → select build (this runs npm run build, compiling .tsdist/).

  5. Click Restart App to load the updated code.

Using Terminal (For Advanced Users / Admins)

  1. Connect to your account via SSH.

  2. Go to the application root (check in cPanel → Setup Node.js App → Application root):

     
    cd ~/api.neobe.com
  3. Activate the Node.js virtual environment (replace 18 with your Node.js version):

     
    source ~/nodevenv/api.neobe.com/18/bin/activate
  4. Run the build command:

     
    npm run build
  5. Restart the app:

     
    touch tmp/restart.txt

Why These Steps Are Needed

  • .ts files are source code.

  • Node.js apps on cPanel/CloudLinux run the compiled .js files from the dist/ folder.

  • Without running npm run build, your changes remain in .ts and never get reflected in production.





Was this answer helpful?

« Back