While Deno 2.0 was released on October 9, 2024, Netlify still has no support for it at the time of writing, and currently only offers Deno 1.46.3
. Trying to deploy a site on Netlify with Deno 2 will give you a build error due to the unrecognized deno.lock
version 4.
Here’s a trick to build a site with Deno 2.0 on Netlify, while we wait for official support.
The error
error: Unsupported lockfile version '4'. Try upgrading Deno or recreating the lockfile at '/opt/build/repo/deno.lock'.
"build.command" failed
Command failed with exit code 1: deno run build (https://ntl.fyi/exit-code-1)
The fix
Simply update your Netlify build command to include Deno’s embedded upgrade tool.
From the UI dashboard:
Site configuration
> Build & deploy
> Build settings
> Configure
> Build command
deno upgrade && deno run build
Using netlify.toml
[build]
command = "deno upgrade && deno run build"
publish = "dist"
Other considerations
In the deploy configuration page, make sure to update the version of Node and Ubuntu Netlify uses to a recent one.