Node.js built-ins on Deno Deploy
We’re excited to announce that starting today, Deno Deploy supports importing
Node.js built-in modules such as http
, fs
, and path
. You can now run
existing Node.js apps at the edge.
Deno Deploy is a next-generation cloud platform built on JavaScript isolates. It runs your JavaScript, TypeScript, and WebAssembly at the edge, in our 35 global regions, close to your users. It scales automatically, from zero to thousands of requests per second. Deno Deploy comes built in with super speedy deployments from GitHub, and a global database.
Starting today, you can use Node.js built-in modules in your Deno Deploy
applications. Modules such as fs
, path
, crypto
, or http
now work out
of the box, enabling you to run existing Node.js apps at the edge, without
hassle.
import { createServer } from "node:http";
import process from "node:process";
const server = createServer((req, res) => {
const message = `Hello from ${process.env.DENO_REGION} at ${new Date()}`;
res.end(message);
});
server.listen(8080);
See this example live: https://dash.deno.com/playground/node-specifiers
This means that you can now run Express applications on Deno Deploy:
import express from "https://esm.sh/express?target=denonext";
const app = express();
app.get("/", (req, res) => {
res.send("Hello from Deno Deploy!");
});
app.listen(8080);
See this example live: https://dash.deno.com/playground/express-demo
Importing of all 47 Node.js built-in modules is supported. However, as all
applications running on Deno Deploy are sandboxed, some modules such as
child_process
do not provide any useful functionality. For a full list of
supported modules and limitations, refer to the documentation:
https://deno.com/deploy/docs/runtime-node
While the Node.js built-in modules behave identically to their native Node.js counterparts, there are cases where our implemenation is not yet perfect. If you encounter any issues, please file an issue.
This is just the humble beginning of our Node.js compatibility story in Deno Deploy. In the above express example, esm.sh is used to load the npm module express. We are working to bring npm specifiers support natively to Deno Deploy. Stay tuned for updates on this soon.