Skip to content

fix: run npm with Node's bin directory on PATH - #6

Open
narcisonunez wants to merge 1 commit into
hungdoansy:mainfrom
narcisonunez:fix/macos-nvm-node-installation
Open

narcisonunez wants to merge 1 commit into
hungdoansy:mainfrom
narcisonunez:fix/macos-nvm-node-installation

Conversation

@narcisonunez

Copy link
Copy Markdown

Fixes #5

Changes

  • New getNpmEnv(npm) prepends dirname(npm) to PATH, applied to installPackage() and removePackage() (the latter passed no env at all).
  • resolveNpm() now collects nvm versions as candidates instead of returning early on existsSync, and the single probe loop runs npm --version with that same env. This also fixes Homebrew: /opt/homebrew/bin/npm was failing the probe with exit 127 and being silently rejected, so a machine without nvm got "npm not found" outright. It also means the nvm result is actually validated rather than assumed.
  • getNpmEnv() updates the existing PATH key case-insensitively. Windows spells it Path, and a plain spread of process.env keeps that casing, writing a separate PATH key would leave two, and Node keeps only the first, wiping the real search path.

Tests

3 new tests in package-manager.test.ts. The execSync mock models the actual failure: it rejects any command whose env lacks the Node bin directory, with env: node: No such file or directory. Each test asserts a branch that fails without this change — PATH prepended for install, the --version probe getting the same env, and a single PATH key when the env uses Path.

All tests are green

https://www.loom.com/share/45010ec5f4ce436fa5512e5c6c06000d

@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

@narcisonunez is attempting to deploy a commit to the hunggggggggggg Team on Vercel.

A member of the Team first needs to authorize it.

@narcisonunez

Copy link
Copy Markdown
Author

Good project. I would like to see the roadmap if possible. I want to be part of it :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package installation fails in packaged macOS app when Node is installed via nvm

1 participant