migrate-to-deno

작성자: denoland

Node.js, npm, Yarn, pnpm 또는 Bun 프로젝트를 Deno로 마이그레이션하거나, 기존 JavaScript 또는 TypeScript 코드베이스에서 Deno를 점진적으로 도입할 때 사용합니다.…

npx skills add https://github.com/denoland/skills --skill migrate-to-deno

Migrating to Deno

Requires Deno 2.9 or later. For general Deno usage once migrated, see the deno skill.

Most Node projects already run under Deno

Deno reads an existing package.json, resolves the same npm packages, writes a real node_modules, runs the same scripts, and supports node: built-ins. TypeScript runs with no build step.

There is usually no code to change — only which binary you invoke. Don't start by rewriting imports to jsr:, swapping dependencies for Deno-specific ones, or restructuring directories. Proposing that is the most common way this goes wrong.

Migrate in rungs

Each rung is independently useful and reversible. Stop wherever suits the project; plenty of teams stop at rung 1.

Rung 1 — Deno as the package manager only

deno install

Reads package.json, resolves the same dependencies, writes node_modules, and creates deno.lock — seeded from any existing package-lock.json, yarn.lock, bun.lock, or pnpm lockfile, so pins and integrity hashes carry over instead of drifting.

The app still runs under node; teammates are unaffected. Commit deno.lock once verified. To back out: delete deno.lock and node_modules, then npm install.

Rung 2 — Run it with Deno

deno run -A main.js      # or: deno -A main.js
deno task build          # runs scripts.build from package.json

Use -A here. The goal is confirming the program works, not designing a permission policy — changing both at once makes failures ambiguous.

Rung 3 — Tighten permissions

Replace -A with the narrowest set that works: run it, read what it asks for, grant exactly that.

deno run --allow-net=api.example.com --allow-read=./config --allow-env=PORT main.js

This buys something Node cannot offer, and is worth doing before deploying.

Rung 4 — Optionally, adopt the built-in toolchain

deno fmt for prettier, deno lint for eslint, deno test for jest or vitest, deno check for tsc, deno watch for nodemon, deno compile for pkg.

Optional, and usually not worth it for an existing project. These are not drop-in replacements; parity is incomplete, so this is a real migration, not a config change. A project happy with prettier, eslint, and vitest should keep them and use Deno as runtime and package manager only. Prefer the built-in tools for new projects. If you do move an existing one, go a tool at a time.

Command equivalents

TasknpmYarnpnpmBunDeno
Install allnpm installyarn installpnpm installbun installdeno install
Addnpm i <p>yarn add <p>pnpm add <p>bun add <p>deno add <p>
Add devnpm i -D <p>yarn add -D <p>pnpm add -D <p>bun add -d <p>deno add -D <p>
Removenpm uninstall <p>yarn remove <p>pnpm remove <p>bun remove <p>deno remove <p>
CI installnpm ciyarn install --immutable†pnpm i --frozen-lockfilebun install --frozen-lockfiledeno ci
Run scriptnpm run <s>yarn <s>pnpm <s>bun run <s>deno task <s>
Run binarynpx <p>yarn dlx <p>pnpm dlx <p>bunx <p>dx <p>
Outdatednpm outdatedyarn outdated‡pnpm outdatedbun outdateddeno outdated
Auditnpm audityarn npm audit†pnpm auditbun auditdeno audit
Whynpm ls <p>yarn why <p>pnpm why <p>bun why <p>deno why <p>
Run a filenode f.jsbun f.tsdeno f.ts
Run TSts-node f.tsbun f.tsdeno f.ts
Watchnodemon f.jsbun --watch f.tsdeno watch f.ts
Formatprettierprettierdeno fmt
Linteslintdeno lint
Testjest, vitestbun testdeno test
Coveragenyc, c8deno coverage
Type-checktsc --noEmittscdeno check
Bundle binarypkg, nexebun build --compiledeno compile

† Yarn Berry (v2+) spelling. Yarn Classic (v1) uses yarn install --frozen-lockfile and yarn audit.

‡ Yarn Classic only — Berry removed yarn outdated.

dx is a separate binary installed alongside Deno, and an alias for deno x. It does not appear in the top-level deno --help output. Like npx, it runs the package with the sandbox disabled.

The four things that actually break

Requires net access to "..." (or read, env, run)

Deno grants nothing by default. Add that specific permission, or -A while still establishing the program works at all.

ReferenceError: require is not defined

A file containing CommonJS is being parsed as ESM. .cjs is always CommonJS, .mjs always ESM; .js and .ts follow "type" in the nearest package.json. For a CommonJS project, set "type": "commonjs".

A dependency is broken, or postinstall never ran

Lifecycle scripts don't run by default. Native addons notice immediately. Approvals are recorded in the config file, so this is one-time:

deno approve-scripts                              # interactive picker
deno install --allow-scripts=npm:better-sqlite3   # or name them directly

A tool cannot find files inside node_modules

Deno's layout is pnpm-style: real files in node_modules/.deno/, exposed via symlinks. Tools assuming npm's flat hoisted tree need:

{ "nodeModulesLinker": "hoisted" }

What has no Deno equivalent

Say so rather than improvising a workaround that won't hold:

  • Yarn Plug'n'Play. Deno creates a real node_modules; .pnp.cjs is unused and .yarnrc.yml resolver settings don't transfer.
  • yarn patch / pnpm patched dependencies. Vendor or fork.
  • overrides / resolutions. Pin via an import map entry instead.
  • Registry and resolver tuning in .npmrc / .yarnrc.yml.
  • Bun build features — macros, HTMLRewriter, HTML entrypoints.

Per-tool details

  • references/FROM_NPM.md — lockfile seeding, node_modules layout, overrides
  • references/FROM_YARN.md — Plug'n'Play, Berry vs Classic, workspaces
  • references/FROM_PNPM.md — pnpm-workspace.yaml, catalog:, patches
  • references/FROM_BUN.md — Bun API translation, bunfig.toml
  • references/NODE_APIS.md — node: built-ins, DENO_COMPAT, CJS/ESM

Further reading

denoland의 다른 스킬

deno
denoland
Deno 프로젝트에서 코드를 작성, 실행, 구성, 검토 또는 디버깅할 때나 새 프로젝트를 생성할 때 사용합니다. deno…를 사용한 의존성 관리를 포함합니다.
deno-deploy
denoland
Use when deploying Deno apps to production, asking about Deno Deploy, or working with `deno deploy` CLI commands. Covers deployment workflows, environment…
deno-expert
denoland
전문가 수준의 Deno 지식으로 코드 리뷰, 디버깅, 모범 사례 적용을 지원합니다. Deno 코드를 검토하거나 고급 Deno 질문에 답변할 때 사용하세요.
deno-frontend
denoland
Fresh 프레임워크 작업, Fresh에서 라우트나 핸들러 생성, Preact로 웹 UI 구축, Deno에서 Tailwind CSS 추가 시 사용합니다. Fresh 2.x를 다룹니다…
deno-guidance
denoland
Deno 프로젝트를 시작하거나, 패키지를 선택하거나, deno.json을 구성하거나, CLI 명령어를 실행할 때 사용합니다. 최신 Deno 애플리케이션을 구축하기 위한 기본 지식을 제공합니다.
deno-project-templates
denoland
새로운 Deno 프로젝트를 스캐폴딩할 때 사용합니다. Fresh 웹 앱, CLI 도구, 라이브러리, API 서버를 위한 템플릿을 최신 모범 사례와 함께 제공합니다.
deno-sandbox
denoland
신뢰할 수 없는 사용자 코드, AI 생성 코드를 실행하거나 격리된 코드 실행 환경이 필요할 때 사용합니다. @deno/sandbox SDK를 다룹니다.
fmt
denoland
저장소의 모든 코드를 포맷합니다. PR을 열거나 변경 사항을 커밋하기 전에 실행하세요.