Deno Builds on Netlify

The Netlify build environment is a Docker image with preinstalled packages like Node and Python. For sensible reasons the packages are rather “stable”, or “outdated”, depending on your sensibilities. Environment variables like NODE_VERSION=16.5 are used to update dependencies if you live on the edge.

If you live too far on the edge, Netlify doesn’t provide enough. Deno is notably missing for my purposes. My website is hosted on Netlify and built with my very own bespoke Deno-powered scuffed static site generator.

To run Deno on Netlify first configure the build command with a shell script:

  command = "./src/"

Then install and run Deno within the script:

curl -fsSL | sh
export PATH="/opt/buildhome/.deno/bin:$PATH"
deno --version
exit 0

Replace deno --version with deno run [...] to run the actual build.

I’m not sure if updating PATH is necessary but it can’t hurt and I’m too lazy to test.

In practice it will download Deno with every build along with all external JavaScript imports. Not the most efficient process but my deployment take around a minute tops so it’s not a big deal. I could manually cache JavaScript dependencies in the repo which might save a few seconds. Though the idea of a deno_modules directory makes me uneasy.

I have a feeling Deno might be officially added to Netlify eventually. Of course, this is all just experimental. Most established build tools are written for Node. I’m really interested in SvelteKit and Astro right now.

Buy me a coffee! Support me on Ko-fi