Express.js
About Express.js
Express.js is a web application framework for Node.js. It provides a set of tools and features to build web applications and APIs quickly and easily. Express.js simplifies common tasks like routing, handling HTTP requests and responses, setting up middleware, and managing sessions. It is lightweight and flexible, allowing developers to structure their applications as they see fit. It is commonly used for building RESTful APIs or server-side applications.
Setup
If you prefer visual guidance, we have a video tutorial available for you to watch here. To follow the written instructions, please continue reading below.
Go into your project root. (If you don't have a project, you can use this example project here.)
How to Setup Express.js
Your Node.js files will go into your user directory (not httpdocs
).
Note: Delete the content inside httpdocs
httpdocs
If you're not using the above example, then create a new file app.js
and put this inside:
Create a new file package.json
and put this inside:
In Plesk, go to "Website & Domains".
Under the domain you'd like to use for Node.js, select Node.js
.
Server Setup
Upload all your files to your server. Then go to the Node.js section and set the following:
Node.js Version: minimum 14.21.0, though it is recommend to use the latest available, currently 17.9.1.
Application Root:
/
(This is the folder where you uploaded your project.)Application Startup File:
app.js
(The entry point of our app, use the file we created earlier.)Here, you're able to configure settings for your application.
Starting the Server
Once all of the above steps are done, press the Enable Node.js
button.
Then you need to press the NPM install
button.
Finally, you will need to wait up to 2 hours for the server to update.
Node.js application deployment requires an Apache restart. Apache is restarted every 2 hours, so please be patient.
If it's been more than 2 hours, and it still isn't working even after you have cleared your cache, then please open a request in the Customer Service forum, making sure to provide your username and domain name so the issue can be investigated.
Once the Node.js application has been deployed, you should be able to go to the domain you selected and see the text Node.js is working.
Last updated