Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno2node/src/deno2node.ts>deno2node

Compile your Deno project to run on Node.js.
Go to Latest
function deno2node
import { deno2node } from "https://deno.land/x/deno2node@v1.10.0/src/deno2node.ts";

Attempts to transform arbitrary ctx.project into a valid Node.js project:

  1. Changes import specifiers to be Node-friendly:

    • changes extension in relative specifiers to .js,
    • replaces some https:// imports with bare specifiers.
  2. Changes *.deno.js imports specifiers to *.node.js (import './deps.deno.ts' -> import './deps.node.js'). This can be used for re-exporting dependencies and other runtime-specific code.

  3. Rewrites remaining https: imports to point into vendorDir, if specified:

    // @filename: tsconfig.json
    {
      "deno2node": {
        "vendorDir": "src/.deno2node/vendor/"
      }
    }
    
  4. Imports Node.js shims for Deno globals from shim file, if specified:

    // @filename: tsconfig.json
    {
      "deno2node": {
        "shim": "src/shim.node.ts"
      }
    }
    

Returns

Promise<void>