Introduction
Node.js domine, mais deux challengers serieux ont emerge :
- Bun : 3x plus rapide que Node, compatible Node API, runtime + package manager + bundler + test runner. Ecrit en Zig.
- Deno : secure-by-default (permissions explicites), TypeScript natif, ESM only, ecrit en Rust. Cree par le createur original de Node.
Prerequis
- VPS Linux Debian / Ubuntu
- Acces root
Partie 1 : Bun
Etape 1 : Installation Bun
curl -fsSL https://bun.sh/install | bash
source ~/.bashrc
bun --version
Ou via npm :
npm install -g bun
Etape 2 : Demarrer une app
bun init monapp
cd monapp
index.ts :
const server = Bun.serve({
port: 3000,
fetch(req) {
return new Response("Hello from Bun!");
},
});
console.log(`Listening on ${server.port}`);
Lancer :
bun run index.ts
Etape 3 : Compatibilite Node
Bun execute la plupart des apps Node sans modification :
cd mon-app-node
bun install # 10-30x plus rapide que npm install
bun run start # execute le script "start" du package.json
Bun lit package.json, supporte require, ESM, JSON imports, fetch natif.
Etape 4 : Bun comme package manager
bun install # installe deps
bun add express # ajouter une dep
bun add -d typescript # dev dep
bun remove express
bun update
Genere un bun.lockb (lockfile binaire) au lieu de package-lock.json.
Etape 5 : Bun bundler
bun build ./src/index.ts --outdir ./dist --minify
Bundle ES modules + JSX + TypeScript en une commande.
Etape 6 : Tests avec Bun
// test/sum.test.ts
import { expect, test } from "bun:test";
test("add", () => {
expect(1 + 1).toBe(2);
});
bun test
Test runner integre, API compatible Jest.
Etape 7 : Deploiement Bun en prod
Via systemd :
sudo nano /etc/systemd/system/monapp.service
[Unit]
Description=Mon app Bun
After=network.target
[Service]
Type=simple
User=www-data
WorkingDirectory=/var/www/monapp
ExecStart=/root/.bun/bin/bun run index.ts
Restart=on-failure
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
sudo systemctl enable --now monapp
Ou avec PM2 :
pm2 start "bun run index.ts" --name monapp
Partie 2 : Deno
Etape 1 : Installation Deno
curl -fsSL https://deno.land/install.sh | sh
source ~/.bashrc
deno --version
Etape 2 : Hello World Deno
// server.ts
Deno.serve({ port: 3000 }, (req) => {
return new Response("Hello from Deno!");
});
deno run --allow-net server.ts
Note le --allow-net : Deno est secure-by-default, vous donnez les permissions explicitement.
Etape 3 : Permissions Deno
deno run --allow-net=:3000 server.ts # uniquement port 3000
deno run --allow-read=./data server.ts # lecture dossier
deno run --allow-write=./logs server.ts # ecriture dossier
deno run --allow-env=NODE_ENV server.ts # variables env
deno run -A server.ts # tout autoriser (a eviter en prod)
Restrictif par defaut = excellent pour la securite.
Etape 4 : Imports
Pas de node_modules ! Imports via URL :
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import express from "npm:[email protected]"; // depuis npm aussi possible
Les imports sont caches localement apres premier download. Reproductible avec un deno.lock.
Etape 5 : Tasks (deno.json)
{
"tasks": {
"start": "deno run --allow-net --allow-env server.ts",
"dev": "deno run --watch --allow-net --allow-env server.ts",
"test": "deno test"
}
}
deno task start
Etape 6 : TypeScript natif
// app.ts
interface User {
id: number;
name: string;
}
function getUser(id: number): User {
return { id, name: "Alice" };
}
deno run app.ts # pas besoin de transpilation
Deno transpile TypeScript a la volee.
Etape 7 : Bundler Deno
deno bundle server.ts dist/server.js
Genere un fichier JS executable n'importe ou.
Etape 8 : Tests Deno
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
Deno.test("add", () => {
assertEquals(1 + 1, 2);
});
deno test
Etape 9 : Deploiement Deno en prod
Systemd :
[Service]
ExecStart=/root/.deno/bin/deno run --allow-net --allow-env /var/www/monapp/server.ts
Ou utilisez Deno Deploy (serverless cloud officiel) pour une option managee.
Etape 10 : Compare a Node.js
| Critere | Node.js | Bun | Deno |
|---|---|---|---|
| Perf | Reference | ~3x faster | similar |
| TypeScript | Need transpiler | Native | Native |
| Compatibility Node | 100% | ~90% | Via npm: |
| Permissions | None | None | Strict opt-in |
| Package manager | npm/yarn/pnpm | bun built-in | URL imports |
| Ecosystem | Tres mature | Croissant | Petit mais croissant |
| Stabilite | Excellente | En croissance | Bonne |
Etape 11 : Quand utiliser quoi
- Node.js : ecosysteme, stabilite, equipe deja formee
- Bun : remplacer Node pour gain de perf, surtout sur npm install
- Deno : nouveau projet TypeScript, focus securite, ou web standards (fetch, Response natif)
Etape 12 : Hybride
Vous pouvez utiliser Bun comme package manager + bundler pour une app Node :
bun install
bun build src/index.ts --outfile dist/index.js
node dist/index.js
Gain de vitesse sur l'install et le build, prod toujours sur Node.
Depannage
Bun : "Module not found"
Bun gere mal certains modules natifs (notamment sharp, canvas). Verifiez la compatibilite :
bun pm ls
Si bloque, repassez sur Node pour cette app.
Deno : "Cannot find module"
Verifiez l'URL d'import. Pour les modules npm :
import express from "npm:express@4";
Et autorisez :
deno run --allow-net --allow-read --allow-env app.ts
Performance basse en cluster
Bun et Deno ne supportent pas nativement le cluster mode comme Node. Utilisez plutot un load balancer devant plusieurs process.
Commandes utiles
Bun
bun --version
bun init
bun install
bun add <pkg>
bun run <script>
bun build <file>
bun test
bun upgrade
Deno
deno --version
deno init
deno run --allow-net app.ts
deno task <task>
deno test
deno fmt # formatter integre
deno lint # linter integre
deno bundle
deno upgrade
Conclusion
Bun et Deno sont des alternatives matures pour 2026 :
- Bun pour la perf et la compatibilite Node
- Deno pour la securite et TypeScript first-class
Pour aller plus loin :
- Testez Bun comme remplacement de npm install (gain immediate)
- Explorez Deno Deploy pour du serverless
- Pour edge computing, regardez Cloudflare Workers (Wasm/V8 isolates)
Ressources
- Bun : https://bun.sh
- Deno : https://deno.land
- Deno docs : https://docs.deno.com
- Comparison runtime : https://github.com/oven-sh/bun/blob/main/docs/runtime/nodejs-apis.md


















