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 JavaScript Runtime on a Linux Server – Running Modern Web Applications
Discover how to install and configure Node.js, Deno, and Bun on your server for efficient JavaScript runtime management → Learn more now
10 November 20264 min read1 Views0 helpful
Introduction
This guide shows you how to install Node.js, Deno, and Bun. The commands must be executed via SSH. If you don’t know how to connect to your server via SSH, please check our First Access (SSH) guide.
FAQ
Frequently asked questions
First, update your system and install Node.js via the package manager with apt install nodejs -y and also install npm with apt install npm.
Node.js is recommended as it is one of the most widely used and popular options. This guide also covers Deno and Bun.
Use the command node -v.
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 installing anything on your server, you should run the update command for your operating system to keep your server secure and up to date.
Code
sudo apt update
Code
sudo yum update
Code
sudo zypper update
Code
sudo dnf update
Installation
First, you need to decide which JavaScript runtime you want to install. There are many online resources that describe each in detail. This guide also includes basic commands and code examples. We recommend Node.js as it is one of the most widely used and popular options.
Installing Node.js Runtime
You can install Node.js either via your Linux distribution’s package manager or with nvm. We recommend apt as it is usually simpler.
Run the following command to install Node.js via the package manager.
Code
apt install nodejs -y
To install Node.js packages for your projects, you also need the npm package manager.
Code
apt install npm
Updating Node.js to the Latest Version
You can check the installed Node.js version with node -v. This is usually not the latest, so you should update to get the newest features. Fortunately, the npm package n offers an easy way to do this.
First, install it with npm install -g n and then you can install any desired Node.js version with n [version] by replacing [version] with the version number.
Tip
It is recommended to always use the latest Long Term Support version. You can do this with n lts.
Installing Node.js with nvm gives you more control to manage different Node.js versions with their own packages.
First, make sure curl is installed on your system, then run this command:
This downloads and runs the nvm installation script from GitHub.
Info
If nvm commands don’t work after installation, reload the bash configuration with source ~/.bashrc.
As with the previous method, you can now install any Node.js version with nvm install v[version]. Use nvm list-remote to see all available versions and nvm list to see all installed versions.
Tip
Install the Long Term Support version with nvm install --lts.
Using Node.js & npm
npm is the official package manager for Node.js. It lets you install packages from the internet.
To start a new Node.js project, first create a new directory (mkdir [project-name]) or navigate to an empty folder and run npm init to start setup. You will be asked for some basic info to create a package.json file. This file is the "config" for your Node.js project.
After initialization, create a file named index.js and write your code inside. As an example, we create a simple HTTP server on port 80 that returns a test message when accessed via localhost:
Start the code with node . and open localhost:80 in your browser to see the result.
Tip
Install external npm packages with npm install [package-name].
Installing Deno Runtime
You can easily install Deno with:
Code
curl -fsSL https://deno.land/install.sh | sh
Tip
Check the installed version with deno --version.
Updating Deno to the Latest Version
Update Deno with:
Code
deno upgrade
Using Deno
To start Deno, create a new file index.ts and write code inside. As an example, we create a simple HTTP server on port 80 that returns a test message when accessed via localhost:
and open localhost:80 in your browser to see the result.
Info
Deno is designed with a focus on security and therefore requires specific permissions like --allow-net to access certain modules.
Installing Bun Runtime
Bun offers two official installation methods: via curl or npm.
Install Bun on your server with the following command:
Code
curl -fsSL https://bun.sh/install | bash
Tip
For other versions, run curl -fsSL https://bun.sh/install | bash -s "bun-v[version]".
If you already have npm installed, you can also simply run:
Code
npm install -g bun
Using Bun
Bun is designed to be faster than other JavaScript engines and has a similar interface to Node.js. Open an empty directory and start with:
Code
bun init
Info
Depending on the chosen language (JS or TS), Bun creates a config file (jsconfig.json or tsconfig.json).
To start Bun, create a new file index.ts and write code inside. As an example, we create a simple HTTP server on port 80 that returns a test message when accessed via localhost:
js
const server = Bun.serve({
port: 80,
fetch(req) {
returnnewResponse('Hello from ZAP-Hosting Docs =)')
},
})
Run the code with:
Code
bun index.ts
and open localhost:80 in your browser to see the result.
By following this guide, you have successfully installed one of the popular JavaScript runtimes on your Linux server.
Server hosting from €2.49 / month, online instantly, DDoS protection included.