Skip to content

Instantly share code, notes, and snippets.

@jimmont
Created January 9, 2026 08:03
Show Gist options
  • Select an option

  • Save jimmont/2354549bc89772cfdc5bc54b37d90965 to your computer and use it in GitHub Desktop.

Select an option

Save jimmont/2354549bc89772cfdc5bc54b37d90965 to your computer and use it in GitHub Desktop.
wrangler in deno, using wrangler in the Deno runtime (npm module)
# running wrangler with deno can have issues with properly caching (npm) dependencies (problem shown below)
# the solution is:
# 1. ensure there's a deno.json with nodeModulesDir 'auto' where running
echo '{"nodeModulesDir": "auto"}' > deno.json
# 2. fix is to cache wrangler dependencies
deno cache npm:wrangler
# 3. now will work where the deno.json resolves
wrangler deploy --dry-run
# here's the problem as I saw it:
wrangler deploy --dry-run
⛅️ wrangler 4.58.0
───────────────────
▲ [WARNING] Processing wrangler.json configuration:
- "unsafe" fields are experimental and may change or break at any time.
✘ [ERROR] Build failed with 2 errors:
✘ [ERROR] Could not resolve
"@cloudflare/unenv-preset/node/console"
../../../../Library/Caches/deno/npm/registry.npmjs.org/wrangler/4.58.0/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-console:1:41:
1 │ ...lt as defaultExport } from "@cloudflare/unenv-preset/node/console";
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "@cloudflare/unenv-preset/node/console" as external to exclude it from the
bundle, which will remove this error and leave the unresolved path in the bundle.
✘ [ERROR] Could not resolve
"@cloudflare/unenv-preset/node/process"
../../../../Library/Caches/deno/npm/registry.npmjs.org/wrangler/4.58.0/_virtual_unenv_global_polyfill-@cloudflare-unenv-preset-node-process:1:41:
1 │ ...lt as defaultExport } from "@cloudflare/unenv-preset/node/process";
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "@cloudflare/unenv-preset/node/process" as external to exclude it from the
bundle, which will remove this error and leave the unresolved path in the bundle.
# to use wrangler in Deno:
deno run npm:wrangler --version
deno run --allow-env --allow-read --allow-net npm:wrangler d1 list
deno run -A npm:wrangler dev
# to install for regular use, eg `wrangler d1 list`
deno install -f -A -n wrangler npm:wrangler@latest
deno install --global -f -A -n wrangler npm:wrangler@latest
# now can do
wrangler --version
# I haven't found a way to cleanly update
# so I find where the cache is
deno info
# will print out the version and path info
Deno version: 2.6.4
DENO_DIR location: /path/to/deno
Remote modules cache: /path/to/deno/remote
npm modules cache: /path/to/deno/npm
Emitted modules cache: /path/to/deno/gen
Language server registries cache: /path/to/deno/registries
Origin storage: /path/to/deno/location_data
Web cache storage: /path/to/deno_cache
# now I uninstall and remove the npm modules cache
deno uninstall -g wrangler
rm -rf /path/to/deno/npm
# then reinstall
deno install --global -f -A -n wrangler npm:wrangler@latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment