Skip to content

fix: only inject portless Node dir into PATH on Windows#247

Open
octo-patch wants to merge 1 commit intovercel-labs:mainfrom
octo-patch:fix/issue-241-node-path-version-manager
Open

fix: only inject portless Node dir into PATH on Windows#247
octo-patch wants to merge 1 commit intovercel-labs:mainfrom
octo-patch:fix/issue-241-node-path-version-manager

Conversation

@octo-patch
Copy link
Copy Markdown

Fixes #241

Problem

augmentedPath in cli-utils.ts unconditionally prepends path.dirname(process.execPath) to the PATH of every child process spawned by portless. When portless is installed via Homebrew (or any tool that uses its own Node), this places portless's Node binary directory before the user's PATH entries, shadowing the version they've configured through their version manager (nvm/fnm/asdf/mise).

Example from the issue:

$ node --version
v24.13.0           # asdf-managed LTS

$ portless myapp sh -c 'node --version'
v25.9.0            # Homebrew's node, injected by portless

Solution

Restrict the nodeBin injection to Windows only. The comment in the original code already explains it's a Windows-specific need — .cmd wrappers in node_modules/.bin require node to be resolvable via PATH on Windows. On Unix-like systems (macOS/Linux), the user's version manager already places their preferred Node first in PATH, so adding portless's Node directory is both unnecessary and harmful.

Testing

  • On macOS/Linux: portless run sh -c 'node --version' now returns the user's version-manager Node, not portless's bundled Node.
  • On Windows: behavior is unchanged — .cmd wrappers in node_modules/.bin still find node correctly.
  • Existing test suite passes.

…-labs#241)

On Unix-like systems (macOS/Linux), the user's version manager
(nvm/fnm/asdf/mise) places their preferred Node binary first in PATH.
Unconditionally prepending process.execPath's directory caused portless's
own Node to shadow the user's chosen version, breaking tools that pin to
a specific Node release.

The nodeBin injection is only needed on Windows, where .cmd wrappers in
node_modules/.bin require node to be findable via PATH. Restrict the
injection to Windows so Unix users retain their version-manager Node.

Co-Authored-By: Octopus <liyuan851277048@icloud.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

Child processes inherit portless's Node instead of the user's — breaks version managers

1 participant