Plesk - Node.js

Introduction

The following Help Center article describes the basic mechanisms of web hosting for Node.js web applications in Plesk.


Prerequisites

  • Plesk server



Managing Node.js Versions

In the Node.js version manager, you can easily install, uninstall, enable, or disable the versions provided by Plesk. You can access the Node.js version manager via ExtensionsMy ExtensionsNode.js Toolkit (Open).


A version can be deactivated by clicking the green checkmark icon and reactivated by clicking the gray X icon. It’s important to note that a version can only be uninstalled if it has been deactivated beforehand and is no longer used by any domains in Plesk.



Enabling Node.js for a Domain for the First Time

If you do not see Node.js in the dashboard view of your subscription, you must enable it for the first time. To do this, navigate as follows: Getting StartedNode.js → Enable Node.js.


\nFrom now on, you can access the Node.js hosting settings via the Developer Tools in the Dashboard view.



Node.js Hosting Settings

The following describes the individual hosting settings for Node.js web applications.

Node.js Version

Here, you can select the Node.js version required for the domain, which is installed on the server; see: <Link to /h2 Manage Node.js Versions, if available>

Package Manager

Plesk provides both npm and Yarn here; you can choose between them to install and manage Node.js packages for your application.

Document Root

This is where the static files of the Node.js web application are located.

Application Mode

In application mode, you can choose between production and development; the latter allows for better debugging of the application via the Phusion Passenger web server.

Application Root

The application root is the directory where the Node.js project is located. This directory typically contains a package.json file, which lists the project dependencies, and the Node.js application’s startup file.

Application Startup File

This file contains the programming instructions for starting and initializing the application and is required by Plesk. If the file is missing, contact the application’s developer.

Custom Environment Variables

This allows you to define your own environment variables that can be accessed while the application is running.



Install Node.js Package Dependencies

The package dependencies for a Node.js project are located in the package.json file. This file must exist so that the package dependencies can be installed via the Plesk Control Panel.


If a package.json file is present in the application root, the dependencies can be installed using the gray + npm Installation button. The required packages will then be located in the node_modules/ directory of the application root.



Application Startup File

The application startup file is always launched by the Phusion Passenger Web Server, which establishes the connection between NGINX and Node.js in a specific way; therefore, it does not matter which app listener port you specify in app.js.


If you are having trouble developing an app.js file that correctly initializes your web application, please contact an agency with experience using Node.js and Plesk servers.



Adding a Package to package.json

To install a package and add it to the dependencies in package.json, you can run the following command or manually add the package to package.json.


npm install <package-name>@<version>



Common Error Messages

nodenv: npm: command not found

This error occurs if no Node.js version has been selected yet. The error message also lists the major version numbers of the Node.js versions currently installed in Plesk.

Sample output:

nodenv: npm: command not found

The `npm' command exists in these Node versions:
  22
  24

To make the npm command executable for Node.js version 22, please run the following command.

nodenv local 22



We’re sorry, but something went wrong


This is an error message from the Phusion Passenger web server, which can have various causes. This output is the web server’s production error output; therefore, for more details, you must set the application mode to development.


Please note that this may pose a potential security risk, as the output may contain confidential information about the structure of your project, depending on the error. For this reason, using the application mode development is recommended exclusively in a protected environment.



Error starting web application (Cannot find module)


The highlighted error message indicates that the application startup file app.js could not be found in the application root. Make sure the file exists in the application root, or rename the corresponding file in the file system or in the Node.js hosting settings so that the web server can launch it.

Error starting web application (EACCES: permission denied, open)


The web server reports that it cannot open the application startup file due to insufficient permissions. Log in to the server via ssh and navigate to the application root directory.

Here, the permissions should be adjusted as follows:

chmod 0644 app.js

The file owner and group should be set as follows:

chown <system_user>:psacln app.js