Articles in this section

How to install and run Node.js application in Plesk?

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
  1. Log in to Plesk.
  2. Upload the Node.js application files, including package.json, to the server using File Manager.
  3. Go to Domains > example.com > Create Website > Node.js and set the application configuration:
    • In Plesk for Linux: the Document Root directory must be the subdirectory of the Application Root directory:

      Click Install

      Note: app.js should be located in Application Root.

    • In Plesk for Windows: the Application Root directory must be same as the Document Root directory.
  4. 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.

  1. Connect to the server using SSH.
  2. Upload the Node.js application files, including package.json, to the domain's application root directory.
  3. Check which settings will be detected and applied, without applying them:

    # plesk ext nodejs --auto-configure -domain example.com -dry-run

    Note: Add the -json option to get machine-readable output.

  4. Configure the application:

    # plesk ext nodejs --auto-configure -domain example.com

  5. After you change the application's content, redeploy it:

    # plesk ext nodejs --redeploy -domain example.com

Additional information

Plesk Administrator's Guide - Hosting Node.js Applications

Was this article helpful?

Comments

2 comments
Date Votes
  • 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

    0
  • 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.

     

    0

Please sign in to leave a comment.