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.
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.
sudo apt update
sudo yum update
sudo zypper update
sudo dnf update
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.
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.
apt install nodejs -y
To install Node.js packages for your projects, you also need the npm package manager.
apt install npm
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.
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:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
This downloads and runs the nvm installation script from GitHub.
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.
Install the Long Term Support version with nvm install --lts.
npm is the official package manager for Node.js. It lets you install packages from the internet.
You can find all npm packages on the official website.
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:
const http = require('http')
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.end('Hello from ZAP-Hosting Docs =)')
})
server.listen(80)
Start the code with node . and open localhost:80 in your browser to see the result.
Install external npm packages with npm install [package-name].
You can easily install Deno with:
curl -fsSL https://deno.land/install.sh | sh
Check the installed version with deno --version.
Update Deno with:
deno upgrade
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:
Deno.serve({ port: 80 }, (_req: Request) => {
return new Response('Hello from ZAP-Hosting Docs =)')
})
Run the code with:
deno run --allow-net index.ts
and open localhost:80 in your browser to see the result.
Deno is designed with a focus on security and therefore requires specific permissions like --allow-net to access certain modules.
Bun offers two official installation methods: via curl or npm.
Install Bun on your server with the following command:
curl -fsSL https://bun.sh/install | bash
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:
npm install -g 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:
bun init
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:
const server = Bun.serve({
port: 80,
fetch(req) {
return new Response('Hello from ZAP-Hosting Docs =)')
},
})
Run the code with:
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.