---
title: "How to publish Deno modules to NPM"
description: "The 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."
url: "https://swe.quest/articles/how-to-publish-deno-modules-to-npm-bc17082adc782014"
canonical: "https://deno.com/blog/dnt-oak"
source: "Deno"
published: "2022-02-28"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["javascript","typescript","build-systems","open-source"]
---

# How to publish Deno modules to NPM

A post on [Deno](https://swe.quest/sources/deno.md), published 2022-02-28, 8 min read, How-to. Original: [https://deno.com/blog/dnt-oak](https://deno.com/blog/dnt-oak)

## Summary

The 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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [Open source](https://swe.quest/tags/open-source.md) (Engineering practices)

## Prerequisites

- Deno basics
- Node.js module systems (ESM/CommonJS) ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))
- npm publishing

## Keywords

Deno, dnt, oak, Node.js, npm, undici

## Related posts

- [Deno 1.34: deno compile supports npm packages](https://swe.quest/articles/deno-1-34-deno-compile-supports-npm-packages-6066648b7bf9ee04.md): Deno · 2023-05-25 · Medium · 6 min read · JavaScript, Runtimes & VMs, Developer tools, TypeScript
  Deno 1.34 lets \`deno compile\` bundle npm packages and their dependencies into a single self-contained executable.
- [dnt — the easiest way to publish a hybrid npm module for ESM and CommonJS](https://swe.quest/articles/dnt-the-easiest-way-to-publish-a-hybrid-npm-module-for-esm-and-commonjs-3ee76ec474a313e6.md): Deno · 2023-07-31 · Medium · 5 min read · TypeScript, JavaScript, Build systems, CI/CD
  dnt (Deno to Node transform) is a build tool that turns a Deno/TypeScript module into an npm package shipping ESM, CommonJS and TypeScript declarations.
- [If you're not using npm specifiers, you're doing it wrong](https://swe.quest/articles/if-you-re-not-using-npm-specifiers-you-re-doing-it-wrong-1ef0f76947ddfda3.md): Deno · 2025-02-13 · Medium · 7 min read · JavaScript, TypeScript, Build systems, Supply chain security
  Deno now recommends importing npm packages with native \`npm:\` specifiers instead of HTTP transpile services like esm.sh or unpkg.
- [Announcing Deno 2](https://swe.quest/articles/announcing-deno-2-5e607a5c7027789d.md): Deno · 2024-10-09 · Easy · 12 min read · JavaScript, TypeScript, Runtimes & VMs, Developer tools, Build systems
  Deno 2 adds backwards compatibility with Node.js and npm, so it runs existing Node projects using package.json, node\_modules and npm workspaces, and supports npm: import specifiers without a manifest.
- [Build Apps in Deno with Frameworks such as React, Vue, Express, and more.](https://swe.quest/articles/build-apps-in-deno-with-frameworks-such-as-react-vue-express-and-more-c17610b126d7b402.md): Deno · 2022-11-16 · Medium · 11 min read · JavaScript, Frontend, React, TypeScript
  Deno 1.28's npm support lets you use npm-distributed frameworks like Express, React and Vue directly via \`npm:\` specifiers.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
