Running a Node.js application on your hosting package

With every package at mijn.host you have the possibility to run a Node.js application. Before you can deploy the application, you will need to go through a few steps. We will explain these steps in this knowledge base article.

What is important to know?

  • It is recommended to first create a staging or dev environment and not go directly into production.
  • Wait with entering sensitive data into the test application until you know how the security of your application works. Unless you already have enough knowledge in-house.
  • For installing and testing a Node.js application, it is useful to know how to establish an SSH connection with your package.

 

Creating the application

Go to DirectAdmin, you can read how to get there in this article: https://mijn.host/kb/hoe-log-ik-in-op-directadmin/

Once you are logged into DirectAdmin, look in the left menu bar for Extra Features and then Setup Node.js App.

create application via DirectAdmin

Next, click on Create Application to create your application.

create application

 

You will now see the following screen:

application settings

Here are a few important fields you need to fill in:

  • Node.js version: Choose the desired Node.js version (choose the recommended version 19 or 20).
  • Application mode: Choose whether this is a production or development installation. First choose Development, after this you can choose Production.
  • Application root: This is the folder where you create the application, you can see it as the public_html folder in web development terms.
  • Application URL: The default URL of your application, for example you can use your-domain.nl/application or leave it empty for just your-domain.nl.
  • Application startup file: The entry point for our server (default app.js). Leave this empty when creating for the first time, the app.js will be created.

Once you have created the application, we will now show you how to create a virtual environment for your application.

It is recommended to work with a virtualenv (virtual environment). This way you can keep all your NPM packages and Node.js versions separated if you want to run multiple applications. In short, it ensures that the software and modules do not conflict with each other but stay neatly with the application where they belong.

You can activate the virtualenv by executing the line at the top of the application you just created via SSH.

application settings

Copy the line. Log in via SSH. And paste the line. In this case:

source /home/username/nodevenv/domains/uw-domein.nl/app/19/bin/activate && cd /home/username/domains/uw-domein.nl/app

After this, you can, for example, use the command 'npm install <softwarepakket>' to install any necessary packages.

$ npm install <softwarepakket>

If you are unable to get your Node.js application working, we are happy to help. Please contact our support department.


Still have questions? Get in touch.