If you're not using npm specifiers, you're doing it wrong
Deno now recommends importing npm packages with native `npm:` specifiers instead of HTTP transpile services like esm.sh or unpkg. Those services lack semver-aware deduplication, so duplicate copies of React can load, and they can't run install hooks for native add-ons or serve bundled data files. Native `npm:` imports resolve versions properly and need no node_modules or package.json, since packages go to a global cache. They also work in Jupyter and the REPL, fall under Deno's permission model with opt-in `--allow-scripts`, and support private registries via `.npmrc`.
Related posts
- Why We Added package.json Support to Deno
Deno easyNoviceDeno added package.json support because its HTTP-import module system, though decentralized and manifest-free, suffers from the Duplicate Dependency Problem, the clunky deps.ts pattern, non-composable import maps, and the limits of transpile servers like esm.sh. Bare specifiers with semver resolution solve deduplication, so Deno now runs existing Node projects while keeping safeguards such as node: prefixes, no arbitrary post-install scripts and permission enforcement. The next major release plans a deno: URL scheme with semver resolution (e.g. deno:oak@12) and encourages import maps in deno.json that mix deno: and npm: specifiers.
- Deno 1.29: Custom npm registry support
Deno mediumAdeptDeno 1.29 adds custom npm registry support via the NPM_CONFIG_REGISTRY environment variable, lets npm specifiers work with `deno install` (with an auto-generated lockfile), and enables npm imports in the REPL. `deno repl` now starts with no permissions by default. The release also removes the unstable Deno.spawn APIs in favor of a unified Deno.Command API, with migration examples, and adds a `createNew` write option and a new `--inspect-wait` debugger flag. Other changes include better errors for unresolved top-level await promises, TypeScript 4.9, and a move toward single-export module layout in std.
- How to publish Deno modules to NPM
Deno mediumAdeptThe oak HTTP middleware framework was ported from Deno to npm using dnt, a build pipeline that rewrites module specifiers, injects shims for Deno and web globals, type checks with tsc, emits ESM/CommonJS plus type declarations, and runs Deno.test suites under Node.js. Porting required shimming web streams, Web Crypto, Blob, fetch/Headers via undici, and a custom ErrorEvent. It also meant removing top-level await so CommonJS output works, and using dnt's mapping feature to swap in a Node.js "http" server abstraction (about 220 lines versus 160 for Deno). Remaining rough edges include differing custom-inspect symbols, undici Headers behaviour around Set-Cookie, and a few platform-branched tests.
- Deno 1.28: Featuring 1.3 Million New Modules
Deno mediumAdeptDeno 1.28 stabilizes npm compatibility, letting programs import any of npm's 1.3 million packages via `npm:` specifiers in imports or import maps, and run npm CLIs with `deno run npm:<pkg>`, with no package.json, install step or node_modules folder by default. Deno's opt-in permission prompts restrict what npm dependencies can access, though post-install scripts, `deno compile` and some Node-layout assumptions remain unsupported. The release also auto-discovers and additively updates a `deno.lock` file whenever a deno.json config exists, stabilizes APIs such as `Deno.bench()` and `Deno.networkInterfaces()`, adds an unstable unified `Deno.Command` subprocess API replacing the `Deno.spawn` family, and upgrades to V8 10.9.
- Deno 1.31: package.json support
Deno mediumAdeptDeno 1.31 adds automatic package.json detection, so dependencies resolve from bare specifiers and package.json scripts run via deno task (simple scripts only for now). The Node.js compatibility layer, roughly 1.5MB that previously lived in std/node, is now embedded in the runtime and loaded from V8 snapshots to cut startup time. Node-API is stabilized, and npm specifiers now work in remote modules without --unstable. FFI pointers become opaque objects or null instead of numbers, which speeds up calls through V8 Fast API, makes pointer spoofing harder and requires migration. Deno.Command is now stable, deno bundle is deprecated, and deno bench gains JSON output.