Plesk for Windows
kb: how-to
Plesk for Linux
Applicable to:
- Plesk for Linux
- Plesk for Windows
Question
How to install and run a Node.js application in Plesk?
Answer
In the Plesk interface
- Log in to Plesk.
- Upload the Node.js application files, including
package.json, to the server using File Manager. - Go to Domains > example.com > Create Website > Node.js and set the application configuration:
- Click NPM install and Run script if necessary.
In the command-line interface (Linux only)
Note: If Node.js is not installed on the server, go to Tools & Settings > Updates and Upgrades > Add/Remove Components and install the Node.js support component.
- Connect to the server using SSH.
- Upload the Node.js application files, including
package.json, to the domain's application root directory. -
Check which settings will be detected and applied, without applying them:
# plesk ext nodejs --auto-configure -domain example.com -dry-run
Note: Add the
-jsonoption to get machine-readable output. -
Configure the application:
# plesk ext nodejs --auto-configure -domain example.com
-
After you change the application's content, redeploy it:
# plesk ext nodejs --redeploy -domain example.com
Comments
The first line for CLI is wrong, because this version:
export PATH=$PATH:/opt/plesk/node/18/bin
shows with
# which npm
/usr/local/bin/npm
So the line must be change to:
export PATH=/opt/plesk/node/18/bin:$PATH
because this adds the line to the beginning of PATH. Now:
# which npm
/opt/plesk/node/18/bin/npm
I had a nodejs/typescript/react app generated at bolt.new. ensure that you're on a lts version of node/npm (even numbered versions are lts.)
application root was the root for the domain “/var/www/domain.name/httpdocs.”
document root turned out to be the directory named “/var/www/domain.name/httpdocs/dist”
application startup file was “src/main.tsx”
then, as root, in the main folder, “npm install” then “npm build” then chown -R <the domain owner:psacln> *
in the node js dashboard don't enable nodejs.
Thought this would help anyone having trouble. It took me a couple of weeks and probably 100 google searches to get this going.
Please sign in to leave a comment.