DocsMigration

npm, package.json, and deno.json

Understand Deno 2 installation, lockfiles, and node_modules modes

Deno 2 can read package.json and deno.json together. Do not delete Node configuration at the start of a migration; first make the existing project install, check, and test under Deno.

Node workflowDeno counterpart
npm installdeno install
npm install lodashdeno install lodash
npm run devdeno task dev (package scripts also work)
package-lock.jsondeno.lock; both may coexist during migration
bare lodash importresolved in package.json projects; Deno-first code may use npm:lodash

Three node_modules modes

ModeUse case
nonenew Deno projects using the global cache
autobundlers, Node-API, or tools require a local directory
manualexisting package.json workflows with an explicit install step
{
  "nodeModulesDir": "auto",
  "tasks": {
    "dev": "deno run --watch -N -E src/main.ts",
    "verify": "deno fmt --check && deno lint && deno check src/main.ts && deno test"
  }
}

Lifecycle scripts do not run unconditionally. When a dependency genuinely needs one, run deno approve-scripts to review and approve interactively (approvals persist to allowScripts in deno.json — the recommended flow since Deno 2.6); deno install --allow-scripts=<package> remains available for one-off approvals. Either way, re-audit whenever the lockfile changes.

Official references: Dependency management and Node and npm compatibility.

Type to search all documentation.