Before you try accessing the app, you need to initialize it first. Let’s begin by installing dependencies – luckily, in Plesk, it’s as easy as clicking the “NPM install” button. This will install all app dependencies according to the package.json file.
Note: you can also use Yarn package manager. The extension will attempt to determine the package manager you need based on the application files. Or you can specify it explicitly in the extension interface.
Then, you need to tune the app startup file. Plesk uses the Phusion Passenger application server to serve Node.js apps. Our demo app repository contains a file named “server.js”. This file is not a part of a typical Express-based app and contains just a few lines of code, but it’s nonetheless necessary for the app to run:
const app = require('./app'); const http = require('http'); http.createServer(app).listen(process.env.PORT);
You can use the idea behind this file when hosting other Node.js apps (e.g. based on a different framework). The last thing you need to do is to change the “Application Startup File” setting to “server.js”.
Leave a Reply