Skip to content

/flags/deno/deno-install-frozen

deno install --frozen: fail when deno.lock is out of date

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
Deno
command
deno install
flag
--frozen[=BOOLEAN], --frozen-lockfile
default
off (deno.lock is updated when dependencies change)

deno install --frozen (alias --frozen-lockfile) installs dependencies only if deno.lock already matches deno.json. When a dependency was added or changed without updating the lockfile, Deno stops with The lockfile is out of date instead of rewriting deno.lock. Use it in CI so every build uses exactly the versions that were committed; locally, run deno install without the flag to update the lockfile and commit it.

Out-of-date lockfile

A first deno install writes deno.lock; then a second dependency is added to deno.json by hand:

bash
cat > deno.json <<'EOF'
{ "imports": { "is-number": "npm:is-number@7.0.0" } }
EOF
npx --yes deno@2 install 2>/dev/null
ls deno.lock
cat > deno.json <<'EOF'
{ "imports": { "is-number": "npm:is-number@7.0.0", "is-odd": "npm:is-odd@3.0.1" } }
EOF
echo "--- deno install --frozen"
npx --yes deno@2 install --frozen 2>&1 | grep -v "^ *$"; echo "exit: ${PIPESTATUS[0]}"
echo "--- deno install (updates the lockfile)"
npx --yes deno@2 install 2>/dev/null; echo "exit: $?"
npx --yes deno@2 install --frozen 2>/dev/null; echo "frozen again, exit: $?"

Output

deno.lock
--- deno install --frozen
Download https://registry.npmjs.org/is-odd
error: The lockfile is out of date. Run `deno install --frozen=false`, or rerun with `--frozen=false` to update it.
changes:
 4 | -    "npm:is-number@7.0.0": "7.0.0"
 4 | +    "npm:is-number@7.0.0": "7.0.0",
 5 | +    "npm:is-odd@3.0.1": "3.0.1"
   | ...
 8 | +    "is-number@6.0.0": {
 9 | +      "integrity": "sha512-Wu1VHeILBK8KAWJUAiSZQX94GmOE45Rg6/538fKwiloUu21KncEkYGPqob2oSZ5mUT73vLGrHQjKw3KMPwfDzg=="
10 | +    },
   | ...
13 | +    },
14 | +    "is-odd@3.0.1": {
15 | +      "integrity": "sha512-CQpnWPrDwmP1+SMHXZhtLtJv90yiyVfluGsX5iNCVkrhQtU3TQHsUWPG9wkdk9Lgd5yNpAg9jQEo90CBaXgWMA==",
16 | +      "dependencies": [
17 | +        "is-number@6.0.0"
18 | +      ]
   | ...
13 | -      "npm:is-number@7.0.0"
23 | +      "npm:is-number@7.0.0",
24 | +      "npm:is-odd@3.0.1"
exit: 1
--- deno install (updates the lockfile)
exit: 0
frozen again, exit: 0

The error lists what changed and how to update the lockfile. After a normal deno install the lockfile matches again and --frozen succeeds.

Where the flag applies

CommandEffect of --frozen
deno installFail instead of writing a new deno.lock
deno run / deno serveFail when the program needs a module that is not locked
deno cacheFail when caching would add entries to the lockfile
deno test / deno taskSame rule for the modules they load
"lock": { "frozen": true } in deno.jsonTurns the flag on for every command
--frozen=falseOverrides the deno.json setting for one command
--no-lockIgnore deno.lock completely (not recommended)

CI setup

bash
deno install --frozen        # restore dependencies exactly as locked
deno check main.ts
deno test --frozen

The lockfile also stores integrity hashes. Deno checks them on every download with or without --frozen; a mismatch means the package content changed and is a separate, more serious error.

Pitfalls

  • deno add updates both deno.json and deno.lock; editing deno.json by hand is the usual way to end up with a stale lockfile. See deno add.
  • An import that is not listed in deno.json at all produces a different error: Import is not a dependency.
  • Other package managers have the same idea under other names: npm ci, yarn install --immutable, pnpm install --frozen-lockfile and bun install --frozen-lockfile.

FAQ

Is --frozen-lockfile the same as --frozen in Deno?

Yes. --frozen-lockfile is an alias of --frozen, and both accept a boolean value, so --frozen=false explicitly allows updates even when deno.json turns freezing on.

How do I make every command use a frozen lockfile?

Set "lock": { "frozen": true } in deno.json. deno run, deno install, deno cache and the others then fail instead of writing deno.lock, until someone runs a command with --frozen=false.

Does --frozen check the integrity of downloaded packages?

Deno always checks downloaded modules against the hashes stored in deno.lock. --frozen adds a second rule: the lockfile itself must not change, so no new or different versions can be resolved.

Sources