Migrate from Node.js
Adopt Deno 2 incrementally while preserving package.json and npm dependencies
Deno 2 can run many existing Node projects. The goal is not to rewrite every import at once; it is to accumulate reversible compatibility evidence.
Incremental adoption
- Pin Deno and record
deno --versionin the existing branch. - Keep
package.json, the current lockfile, and the existingnode_modulesstrategy; run one side-effect-free script first. - Execute current tests and classify failures in Node APIs, native addons, loaders, and lifecycle scripts.
- Introduce
deno.jsontasks and run Deno commands beside current commands. - Remove old tools or lockfiles only after CI, developer, and production verification.
Compatibility conventions
import { readFile } from "node:fs/promises";
import express from "npm:express";
Deno can also resolve common bare npm imports from package.json. Whether a local node_modules is enabled or required depends on project configuration and dependency behavior; one mode does not fit every package.
High-risk areas
- Node-API addons, postinstall scripts, and binary downloads;
- custom ESM loaders, resolution hacks, and implicit extensions;
- Jest/Vitest globals, fake timers, and snapshot differences;
- undeclared environment, filesystem, and network access;
- edge behavior in
process, Buffer, streams, and Node APIs.
Official references: Node compatibility and Migrate to Deno.