Expand description
Resolve the Node.js binary used to spawn Cocoon.
Ladder (first hit wins, cached in OnceLock):
Pick override → shipped (Resources/Node/bin/node) →
fnm → volta → asdf → nvm → homebrew → PATH node.
Each step logs its outcome so the resolved source is visible in the log.
Modules§
- Check
MinMajor - Warn when the resolved Node’s major version is below
Require. Does NOT fail the spawn - Cocoon’s bundled code mostly degrades gracefully on older engines and operators should be free to experiment on unreleased Node without a hard gate. - Expand
Home - Expand a leading
~/against$HOME. Returns the input unchanged ifHOMEis unset or the path doesn’t start with~/. - Node
Executable Name - Platform-specific filename for the Node executable.
- Node
Source - Where the resolved Node binary came from. Ordered by preference (override
first, PATH last).
AsLabelreturns the lowercase ident used in log lines. - Query
Node Version - Run
node --versionon the resolved binary and return its reported version string (e.g.v24.8.0). ReturnsNonewhen the binary cannot be spawned (barenodefallback under a misconfigured PATH) or when it exits non-zero. No timeout -node --versionnever blocks. - Resolve
Node Binary - Resolve the Node binary used to spawn Cocoon and cache for the life of
the process. If everything fails returns
nodesoCommand::newstill tries a bare PATH lookup at spawn time, matching legacy behaviour while logging the chain of misses. - Resolve
Uncached - First-hit-wins ladder over the manager-specific lookups. Falls back to
nodeon PATH if every manager misses. - Resolved
Node - Result of a Node binary resolution attempt. Carries both the path and the source so log lines can distinguish shipped Node from system Node.
- TryAsdf
- asdf shim lookup. The shim resolves the active
.tool-versionsentry on every call. - TryFnm
- fnm shim lookup.
FNM_MULTISHELL_PATH(active shell) wins; otherwise probe the per-OS multishell cache directories. - TryHomebrew
- Homebrew lookup. Apple Silicon, Intel macOS, and Linuxbrew probe paths.
- TryNvm
- nvm lookup.
NVM_BINwins (set inside an nvm-sourced shell). Fallback walks$NVM_DIR/versions/nodeand picks the lexicographically largest version (rough proxy for “latest installed”). - TryOverride
Pickenv-var override. ReturnsSomewhen the path exists, logs a warning when it doesn’t, and returnsNoneotherwise.- TryShipped
- Bundled Node lookup. Production: Tauri ships Node under
Resources/Node/bin/node(Resources/Node/node.exeon Windows). Dev: same layout next to the executable so the dev build dogfoods the same resolution path. - TryVolta
- Volta shim lookup.
VOLTA_HOMEwins; otherwise~/.volta. Volta installs shim binaries under<VOLTA_HOME>/bin.