1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Modify the configuration of a Node.js site
This guide explains how to adjust the configuration of a Node.js site hosted on the Infomaniak infrastructure to adapt the behavior of your application according to its evolution, its dependencies or your technical preferences.
Prerequisites
- Install a Node.js site on your hosting.
- Test your modifications locally before applying them to production.
- Check that your scripts (
start
,build
) are properly defined in yourpackage.json
file. - If you modify the structure of your project, remember to adjust the execution folder and the associated commands.
- The listening port defined in the Manager must absolutely correspond to the one used in the application's code.
Access the configuration
Each site has a dedicated dashboard to control the application (start, stop, restart), access the execution console, manage Node.js versions, configure domains and activate SSL certificates:
- Click here to access the management of your product on the Infomaniak Manager (need help?).
- Click directly on the name assigned to the relevant product.
- You can open the console, stop the project (a maintenance page will be applied) or restart it.
- To access the advanced settings, click on Manage under Advanced Settings:
- Click on the Node.js tab to access the settings:
Apply the changes
To do this:
- Save the changes from the Manager interface.
- Restart your application for the changes to take effect.
Refer to this other guide if you encounter any issues.
Main commands
Execution folder
The execution folder indicates the location on the server where build and launch commands will be executed. It should point to the root directory of your application, i.e., where your package.json
file is located.
For example, you can specify for the project root:
./
or if your application is in a subfolder named app
:
./app
or if it is located in a backend
folder:
./backend
Optional build command
If your Node.js application requires a compilation step before it can be run, enter a build command in the designated field. This command will be executed automatically before the application starts.
For example, you can specify:
npm install && npm run build
or, if you use yarn :
yarn install && yarn build
If your project does not require any compilation, this field can be left empty.
Launch command
The launch command corresponds to the instruction used to start your application. It must be identical to the one you use locally to run the project.
For example, you can specify:
node index.js
npm start
or
yarn start
This command should allow you to directly start the server or the entry point of your application as defined in your development environment.
Listening port
Your application must listen on a specific port that is defined in the Manager. This port is passed to your application via an environment variable PORT
.
Example in your Node.js code:
const port = process.env.PORT || 8080;
app.listen(port, () => {
console.log(`Application lancée sur le port ${port}`);
});
Make sure this port is properly accounted for in your code.
Node.js version
You can select the Node.js version that your site should use. It is recommended to use a stable and always supported version to ensure the security and compatibility of your application.