fix: run npm with Node's bin directory on PATH - #6
Open
narcisonunez wants to merge 1 commit into
Open
narcisonunez wants to merge 1 commit into
narcisonunez wants to merge 1 commit into
Conversation
|
@narcisonunez is attempting to deploy a commit to the hunggggggggggg Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Good project. I would like to see the roadmap if possible. I want to be part of it :D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5
Changes
getNpmEnv(npm)prependsdirname(npm)toPATH, applied toinstallPackage()andremovePackage()(the latter passed noenvat all).resolveNpm()now collects nvm versions as candidates instead of returning early onexistsSync, and the single probe loop runsnpm --versionwith that same env. This also fixes Homebrew:/opt/homebrew/bin/npmwas 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 itPath, and a plain spread ofprocess.envkeeps that casing, writing a separatePATHkey would leave two, and Node keeps only the first, wiping the real search path.Tests
3 new tests in
package-manager.test.ts. TheexecSyncmock models the actual failure: it rejects any command whose env lacks the Node bin directory, withenv: node: No such file or directory. Each test asserts a branch that fails without this change — PATH prepended for install, the--versionprobe getting the same env, and a single PATH key when the env usesPath.All tests are green
https://www.loom.com/share/45010ec5f4ce436fa5512e5c6c06000d