How to Install npm Packages for a Node.js App in cPanel
On cPanel shared hosting you install your Node.js app's npm packages either with the one-click "Run NPM Install" button, or by entering the app's virtual environment and running npm commands yourself. Both use your project's package.json as the source of truth.
The easy way: Run NPM Install
- Open Setup Node.js App in cPanel.
- Make sure your
package.jsonis in your application root. - Click Edit on the app, then click Run NPM Install.
cPanel reads your package.json and installs the listed dependencies into the app.
The flexible way: the virtual environment
For installing a specific package or running other npm commands, use the app's virtual environment. In Setup Node.js App, cPanel shows an "Enter to the virtual environment" command — copy it and run it over SSH. Once inside, npm targets the correct Node version:
npm install express
Keep package.json accurate
Always list your dependencies in package.json so they can be reinstalled reliably — for example after changing your Node version. Commit your lockfile too for consistent installs.
After installing
Restart the app so it picks up the new packages — see restarting a Node.js app in cPanel. If installation fails, see fixing npm install failures.
Frequently asked questions
Do I need SSH to install packages?
Not for a standard install — the Run NPM Install button works from cPanel. SSH is only needed if you want to install specific packages or run custom npm commands in the virtual environment.
Why aren't my packages being found?
Ensure package.json is in the application root cPanel expects, then run the install and restart. Installing outside the virtual environment can put packages where the app cannot see them.
Should I upload node_modules?
No — upload your package.json and lockfile and let the install build node_modules on the server, so packages are built for the server's environment.
Was this article helpful?