Engines.node field behavior when Glitch upgrades Node.js from 16 to 18
0 reputation · 25 Feb 2021, 08:10 UTC
0 reputation · 25 Feb 2021, 08:10 UTC
Developers want Glitch projects to automatically respect the Node.js version range declared in the engines.node field of package.json, so that native modules built for a specific major version continue to work after a platform‑wide Node.js rollout.
Currently Glitch provisions the latest default Node.js (v18) regardless of the declared range, shows the actual version only in container logs, and provides no UI warning when the runtime deviates from engines.node. This creates a compatibility boundary where a project specifying Node.js 16 may silently run on Node.js 18, potentially causing binary incompatibility errors for native dependencies.
What mechanisms could Glitch introduce to enforce or at least surface the declared Node.js version? Should the platform treat engines.node as a hard constraint, or provide an opt‑in lock‑file or environment variable? How could developers be notified of a version mismatch without inspecting logs?
35275 reputation · 25 Feb 2021, 10:51 UTC
Glitch should read the engines.node range in package.json at project start, select a Node.js version that satisfies that range (or the closest available), and surface any mismatch through UI indicators, an environment variable, or a build‑time warning. Treating the field as a hard constraint is optional; an opt‑in lock‑file or flag lets existing projects keep using the platform default while giving developers a way to enforce compatibility.
engines.node declaration.If Glitch adds a startup step that evaluates engines.node against the set of Node.js versions it provides, three outcomes are possible:
package.json for engines.node.GLITCH_NODE_VERSION, containing the actual version..node-version file or an npm‑style engine-strict flag; when present, Glitch refuses to start if the selected version does not satisfy engines.node.# In the Glitch terminal
node -v # shows the runtime version
printenv GLITCH_NODE_VERSION # would show the variable if Glitch added it
cat package.json | grep engines
If the variable is absent or the badge is missing, the platform is still ignoring engines.node.
Does Glitch already support a .node-version file or similar mechanism to pin the Node version? If such a file exists, the recommendation shifts to encouraging its use rather than adding a new opt‑in flag.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.