Node.js compability mode
Starting with v1.15 Deno provides Node compatiblity mode that can be activated
--compat flag in CLI.
⚠️ Currently using compatiblity mode requires the
--unstableflag, and if you are loading CJS modules, the
--allow-readflag is needed too.
When using compatibility mode there are a few things happening behind the scenes:
Node globals are available in the global scope, so you can access
clearImmediate. This is done by executing
Node built-in modules are set up on startup, eg.:
import fs from "fs";
import fs from "node:fs";
const fs = require("fs");
const fs = require("node:fs");
Deno will support Node resolution algorithm so importing packages using "bare" specifiers will work. For details on how module resolution works check Node documentation on CJS and ES modules.
Node.js built-in modules
Following built-in Node modules are currently supported:
Following modules are not yet implemented:
If you try to run Node code that requires any of the not implemented modules, please open an issue in https://github.com/denoland/deno_std/issues with example code.
Currently, the compability mode does not support TypeScript.
In the upcoming releases we plan to add support for a
types field in
package.json, to automatically lookup types and use them during type checking.
In the long term, we'd like to provide ability to consume TypeScript code authored for the Node.js runtime.