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)
-
Log in to cPanel.
-
Go to Setup Node.js App.
-
Locate your app (example:
api.neobeststar.com
). -
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.ts
→dist/
).
-
-
Click Restart App to load the updated code.
Using Terminal (For Advanced Users / Admins)
-
Connect to your account via SSH.
-
Go to the application root (check in cPanel → Setup Node.js App → Application root):
-
Activate the Node.js virtual environment (replace 18 with your Node.js version):
-
Run the build command:
-
Restart the app:
Why These Steps Are Needed
-
.ts
files are source code. -
Node.js apps on cPanel/CloudLinux run the compiled
.js
files from thedist/
folder. -
Without running
npm run build
, your changes remain in.ts
and never get reflected in production.