Skip to content

Deno Runtime Guide

tywrap's Deno subprocess support is experimental and untested in CI. It uses the same NodeBridge as Node.js, and Deno requires the npm: prefix for npm imports.

Deno Deploy limitation

Deno Deploy does NOT support subprocess execution. Because NodeBridge spawns a Python subprocess, it cannot run in Deno Deploy.

Alternatives for Deno Deploy:

  • Use PyodideBridge, which runs Python in-browser via WebAssembly (no subprocess)
  • Use HttpBridge, which connects to a remote Python server over HTTP

Installation

bash
deno add npm:tywrap
pip install tywrap-ir

Basic Setup

typescript
import { NodeBridge } from 'npm:tywrap';
import { setRuntimeBridge } from 'npm:tywrap/runtime';

setRuntimeBridge(
  new NodeBridge({
    pythonPath: 'python3',
    timeoutMs: 30000,
  })
);

Required Permissions

Deno requires explicit permission flags for subprocess execution:

bash
deno run \
  --allow-run=python3 \
  --allow-read \
  --allow-env \
  your-script.ts
FlagReason
--allow-run=python3Spawn the Python subprocess
--allow-readRead Python scripts and config files
--allow-envRead TYWRAP_* and PATH environment variables

Type Checking

bash
deno check src/index.ts

Configuration Options

See the Node.js guide for the full NodeBridgeOptions reference. All options work identically in Deno.

When to Use Each Bridge in Deno

ScenarioBridgeNotes
Local Deno scriptNodeBridgeNeeds --allow-run
Deno DeployPyodideBridgeWebAssembly, no subprocess
Deno Deploy + heavy Python libsHttpBridgePython runs on a separate server

Environment Variables

The same TYWRAP_* env vars work under Deno. See the environment variables reference.

Troubleshooting

PermissionDenied: Requires run access to "python3": add --allow-run=python3 to your deno run command.

NotSupported: Subprocess access is not allowed: you are running in Deno Deploy. Switch to PyodideBridge or HttpBridge.

See the Node.js troubleshooting guide for additional patterns.

Released under the MIT License.