Focal build image installs default Node (v16)

My Netlify site is on the Focal build image. It’s been around a few years, and was recently upgraded from the legacy Trusty build image. So there are cached memories of old dependency versions, like Ruby and Python, etc. (The solution of re-linking my repository as suggested here, Build fails with Focal image due to unwanted old Ruby - #4 by hillary, didn’t work, but that’s for another topic).

The Focal docs say Node v16 is the default version.

I’ve got a .node-version file that declares v16 as the dependency.

Yet my Netlify build installs Node v16 rather than just using it, like it does so for Python, Ruby, and PHP (see log snippet below).

Why is this happening? How to cut the install time down by relying on the default v16?

11:17:31 AM: Starting build script
11:17:31 AM: Installing dependencies
11:17:31 AM: Python version set to 2.7
11:17:31 AM: Attempting node version '16' from .node-version
11:17:31 AM: Downloading and installing node v16.10.0...
11:17:32 AM: Downloading https://nodejs.org/dist/v16.10.0/node-v16.10.0-linux-x64.tar.xz...
11:17:32 AM: Computing checksum with sha256sum
11:17:32 AM: Checksums matched!
11:17:35 AM: Now using node v16.10.0 (npm v7.24.0)
11:17:35 AM: Started restoring cached build plugins
11:17:35 AM: Finished restoring cached build plugins
11:17:35 AM: Attempting ruby version 2.7.2, read from environment
11:17:37 AM: Using ruby version 2.7.2
11:17:37 AM: Using PHP version 8.0
11:17:37 AM: Started restoring cached node modules

Hi @brianzelip,

I think Node is always downloaded and installed from its servers. By default it means even if you don’t specify Node version, version 16 will be downloaded. The other softwares are pre-installed, and thus, need not be downloaded. But I think the Node defaults to ^version which means, it will use the latest version in that major version. So, if ^16 is specified, it will use the latest 16.x.x release.

But I’m not sure why you’re trying to cut down on build time with Node.

It’s taking like a second in the build logs. Even if you consider the wait time till it starts the next step, it’s 3 to 4 seconds.

2 Likes

Great point @hrishikesh! I didn’t consider looking at the timestamp, just noticed something that I could try to control.

Anyways, that log snippet was from the first time I deployed with my project updated for the new build image. Since then, the log reads that the Node version is already installed.

Thanks for the followup!

1 Like