Skip to main content

Module NodeResolver

Module NodeResolver 

Source
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§

CheckMinMajor
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.
ExpandHome
Expand a leading ~/ against $HOME. Returns the input unchanged if HOME is unset or the path doesn’t start with ~/.
NodeExecutableName
Platform-specific filename for the Node executable.
NodeSource
Where the resolved Node binary came from. Ordered by preference (override first, PATH last). AsLabel returns the lowercase ident used in log lines.
QueryNodeVersion
Run node --version on the resolved binary and return its reported version string (e.g. v24.8.0). Returns None when the binary cannot be spawned (bare node fallback under a misconfigured PATH) or when it exits non-zero. No timeout - node --version never blocks.
ResolveNodeBinary
Resolve the Node binary used to spawn Cocoon and cache for the life of the process. If everything fails returns node so Command::new still tries a bare PATH lookup at spawn time, matching legacy behaviour while logging the chain of misses.
ResolveUncached
First-hit-wins ladder over the manager-specific lookups. Falls back to node on PATH if every manager misses.
ResolvedNode
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-versions entry 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_BIN wins (set inside an nvm-sourced shell). Fallback walks $NVM_DIR/versions/node and picks the lexicographically largest version (rough proxy for “latest installed”).
TryOverride
Pick env-var override. Returns Some when the path exists, logs a warning when it doesn’t, and returns None otherwise.
TryShipped
Bundled Node lookup. Production: Tauri ships Node under Resources/Node/bin/node (Resources/Node/node.exe on Windows). Dev: same layout next to the executable so the dev build dogfoods the same resolution path.
TryVolta
Volta shim lookup. VOLTA_HOME wins; otherwise ~/.volta. Volta installs shim binaries under <VOLTA_HOME>/bin.