You decide which services we may enable for analytics, personalization, and external content.
We use cookies and similar technologies on our website to personalize content, embed external media, and better understand how individual areas are used.
Necessary cookies
These entries support essential functions such as security, stability, and form processing.
Optional sections
AnalyticsMarketingPersonalizationExternal media
Your data may be processed with your consent or on the basis of legitimate interests. In the cookie settings, you can reject or explicitly allow each optional category.
Some services process personal data in third countries. By consenting, you also agree to this transfer. You can find more information in our Privacy Policy.
You can reopen and change your selection at any time. · 1.0.2
Setting Up Node.js on a Linux Server – Launch Modern JavaScript Applications
Discover how to set up a stable Node.js environment for scalable real-time applications using Docker and system preparation → Learn more now
10 November 20263 min read0 Views0 helpful
Introduction
Node.js is a cross-platform, open-source JavaScript runtime environment that executes JavaScript code outside the browser, for example on servers or in command-line tools. Based on the V8 engine, it supports asynchronous, event-driven I/O, making it extremely efficient for building scalable network and real-time applications.
The “JavaScript everywhere” paradigm allows developers to use a single language for both backend and frontend.
FAQ
Frequently asked questions
First, update your system with sudo apt update && sudo apt upgrade -y. Since Node.js runs in multiple Docker containers, you then need to install Docker as a dependency.
Node.js is a cross-platform, open-source JavaScript runtime that executes JavaScript outside the browser, based on the V8 engine with asynchronous, event-driven I/O.
Feedback
Was this article helpful?
Your feedback helps us prioritize and improve content.
0 of 0 Users found this article helpful.
Personal support
Need more help than the guide provides?
Our ZAP support team knows your product — briefly describe your issue and we'll help you personally.
Navigation
Software
Preparation
Before setting up Node.js, you should prepare your system. This includes updating your operating system to the latest version and installing all necessary dependencies. This preparation ensures a stable environment and helps avoid issues during or after installation.
Update System
To keep your system running with the latest software and security updates, always start with a system update. Run the following command:
Code
sudo apt update && sudo apt upgrade -y
This ensures your system has the newest security patches and software versions before proceeding with the installation.
Install Dependencies
After the update is complete, you can proceed with installing dependencies. Node.js will run on your system in multiple Docker containers. Therefore, Docker must be installed first. Run the following commands:
Code
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
For a detailed step-by-step guide on installing and using Docker, see our Docker tutorial.
Installation
Once all prerequisites are met and preparations are complete, you can start installing the Node.js application.
To use Node.js in an isolated environment, first download the official Alpine-based image. Run the following command to pull the latest Node.js 22 image to your system and prepare it for container deployments:
Code
docker pull node:22-alpine
Then you can start a container based on this image and open a shell session inside it. Use the following command to start the container interactively. The --rm option ensures the container is automatically removed when you exit, keeping your host clean.
Code
docker run -it --rm --entrypoint sh node:22-alpine
Inside the container, check the installed Node.js version with node -v, which should display v22.19.0. Check the npm version with npm -v, expected to be 10.9.3. This confirms the image provides the correct versions of Node.js and npm and is ready to use immediately.
Configuration
After starting the Node.js container, it is recommended to configure important Node.js settings directly in the environment. A common approach is setting environment variables, for example:
Code
export NODE_ENV=production
This activates production mode, enables performance optimizations, and adjusts logging. For development purposes, you can set NODE_ENV=development to enable detailed error messages and debugging features.
A well-structured project folder is important, starting with a configuration file you create using the following command:
Code
npm init -y
This generates a package.json file that defines dependencies, scripts, and metadata for your project. It is the central configuration file for every Node.js application.
You can then install dependencies with npm install <package>, while development dependencies are added with npm install <package> --save-dev. The scripts section in package.json allows you to define custom commands like npm start or npm run build to simplify execution and project management.
For advanced setups, Node.js can be customized with .npmrc or .nvmrc files to enforce private registries, cache options, or a specific Node.js version. This ensures your application runs consistently across different environments.
Completion and Further Resources
Congratulations! You have now successfully installed and configured Node.js on your VPS/Dedicated Server. We also recommend checking out the following resources that can help you with server configuration: