Migrate from Node.js to Deno
A Deno 2 migration route that preserves rollback and verifies compatibility layer by layer
Deno 2 reads package.json, resolves npm packages, and runs a broad set of Node APIs. Migration should not begin by rewriting imports. It should begin by proving that the application still satisfies its tests and production constraints on another runtime.
Four-stage route
1. Establish a baselinePin versions, keep the current install flow, and run side-effect-free scripts and tests.2. Align packages and configUnderstand package.json, deno.json, lockfiles, and node_modules modes.3. Map APIs deliberatelyKeep working node: APIs and adopt Web or Deno APIs only where they help.4. Resolve compatibilityHandle CommonJS, native addons, install scripts, permissions, and tests.
Acceptance at every stage
deno install
deno check src/main.ts
deno test
deno task start
Do not remove the old lockfile, runtime command, or deployment path until CI, developer machines, and the target production environment all pass. Change only one of runtime, package management, testing, framework, or deployment in a single migration step.
Official references: Migrate to Deno and Node and npm compatibility.