Node.js built-in APIs
You are viewing legacy documentation for Deno Deploy Classic. We recommend migrating to the new Deno Deploy platform.
Deno Deploy Classic natively supports importing built-in Node.js modules like
fs, path, and http through node: specifiers. This allows running code
originally written for Node.js without changes in Deno Deploy Classic.
Here is an example of a Node.js HTTP server running on Deno Deploy Classic:
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);
_You can see this example live here: https://dash.deno.com/playground/node-specifiers_
When using node: specifiers, all other features of Deno Deploy Classic are
still available. For example, you can use Deno.env to access environment
variables even when using Node.js modules. You can also import other ESM modules
from external URLs as usual.
The following Node.js modules are available:
assertassert/strictasync_hooksbufferchild_processclusterconsoleconstantscryptodgramdiagnostics_channeldnsdns/promisesdomaineventsfsfs/promiseshttphttp2httpsmodulenetospathpath/posixpath/win32perf_hooksprocesspunycodequerystringreadlinestreamstream/consumersstream/promisesstream/webstring_decodersystimerstimers/promisestlsttyurlutilutil/typesv8vmworker_threadszlib
The behavior of these modules should be identical to Node.js in most cases. Due to the sandboxing behaviour of Deno Deploy Classic, some features are not available:
- Executing binaries with
child_process - Spawning workers using
worker_threads - Creating contexts and evaluating code with
vm
Note: the emulation of Node.js modules is sufficient for most use cases, but it is not yet perfect. If you encounter any issues, please open an issue.