When I was in the process of working on one of my Glitch projects, I discovered an error in the way Glitch detects what version of Node to run.
The current way uses the following function found at /opt/watcher/app-types/utils.sh
:
parse-node-version () {
local raw=$1;
echo "$raw" | grep -o '[0-9]\+' | head -n 1
}
As you can see, this approach only take the major version from the version string, and disregards everything else.
This is propably not a big problem for the majority of projects, however, it can have some undesired consequences; E.g, the version strings 12.x
and 12.3.x
will evaluate to the same version: 12
.
In my case, I had specified the version >=12.9.0
because my code relies on features introduced in this version of Node. However, this caused Glitch to use Node version 12.0.0
, the highest available version of Node 12, instead of using the available Node 14 version: 14.15.2
.
For now, I fixed it by defining a slightly modified install and start script, which in turn calls a modified version of parse-node-version
capable of correctly selecting a valid Node version based on a version range. But, it would be nice not having to do that in the future.