Skip to content

Conversation

@EDM115
Copy link

@EDM115 EDM115 commented Oct 23, 2025

Important

Full disclosure : Most of the code here has been written by OpenAI Codex.
Although I was able to check and fix the part related to FNM (which now works), I can't be sure about NVM, nvm-windows and Volta. My machine is sadly not powerful enough to spin up Windows & Linux VMs to test that out. Speaking of tests, I admit it would be better to add some related to the added functionality but I have no clue how to properly test this.
I am also unsure about any format guidelines (I did ran just fmt) or if this should be put somewhere else than in the extension.ts.
I do not really expect this PR to be merged, at least as-is. Consider this more as an example on how to implement #13497

What does it do ?

When Node.js isn't on the PATH by default but rather added dynamically by a 3rd-party tool (mostly to manage on-the-fly multiple Node versions), the type aware checking in the VS Code extension will fail to run.

  • should work cross-platform
  • tested with fnm on windows, should also work with nvm, nvm-windows and volta
  • the added checks should only run when typeAware is enabled and Node isn't already in the PATH
  • regarding fnm, I prefered to parse its env output once rather than using it as a middleman with exec node

Fixes an issue ?

fix #13497

Additional reference

Workaround while this isn't merged

For FNM users, add the path to the default alias to your PATH, by default $HOME\AppData\Roaming\fnm\aliases\default on Windows or if you customized the install dir C:\path\to\fnm\aliases\default

…ATH`

- should work cross-platform
- tested with fnm on windows, should also work with nvm, nvm-windows and volta
- the added checks should only run when typeAware is enabled **and** Node isn't already in the `PATH`
Copilot AI review requested due to automatic review settings October 23, 2025 12:11
@EDM115 EDM115 requested a review from camc314 as a code owner October 23, 2025 12:11
@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 23, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added A-editor Area - Editor and Language Server C-enhancement Category - New feature or request labels Oct 23, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds automatic Node.js detection for type-aware linting in the VS Code extension when Node.js isn't directly available on the PATH. It implements support for popular Node.js version managers (fnm, nvm, nvm-windows, and Volta) to ensure the language server can locate Node.js even when managed dynamically.

Key Changes:

  • Implements environment resolvers for fnm, nvm, nvm-windows, and Volta to locate Node.js installations
  • Adds PATH manipulation logic to prepend detected Node.js binary directories
  • Only activates when type-aware linting is enabled and Node.js isn't already on PATH

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +234 to +237
// The following path construction assumes the standard Unix-like nvm directory structure :
// $NVM_DIR/versions/node/<version>/bin
// nvm-windows is handled separately above via NVM_SYMLINK
const binDir = join(nvmDir, 'versions', 'node', sanitized, 'bin');
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded path segments 'versions', 'node', and 'bin' represent magic values that encode nvm's directory structure. Consider extracting these as named constants (e.g., 'NVM_VERSIONS_DIR', 'NVM_NODE_DIR', 'NVM_BIN_DIR') to improve maintainability and make the directory structure assumption explicit.

Copilot uses AI. Check for mistakes.
@EDM115
Copy link
Author

EDM115 commented Oct 23, 2025

example of a working type-aware lint in VS Code with FNM detected

@EDM115 EDM115 changed the title feat(vscode): properly get Node.js when it isn't by default on the PATH fix(vscode): properly retrieve Node.js when it isn't by default on the PATH Oct 23, 2025
@github-actions github-actions bot added the C-bug Category - Bug label Oct 23, 2025
@EDM115

This comment was marked as outdated.

@Sysix
Copy link
Member

Sysix commented Oct 24, 2025

I am not sure if this is something a VSCode extension should solve.
Searching for the node script node_modules/.bin/tsgolint should be an integration detail of the server.
The server is using the same environment variable as the extension, I would say this is a (user) setup problem.

I have no problems with my nvm setup, it auto added the node path to the PATH.
For fnm I found this windows issue: Schniz/fnm#1410.

Other extension are providing a name.nodePath option, maybe this is better alternative?

@EDM115
Copy link
Author

EDM115 commented Oct 24, 2025

hmmm indeed that's actually clever
I agree on the fact that it's a misconfiguration on fnm end

once again it was just a try on my end to fix the issue, but you guys know better what to actually do :)

graphite-app bot pushed a commit that referenced this pull request Nov 6, 2025
see #14920 (comment)

> When Node.js isn't on the PATH by default but rather added dynamically by a 3rd-party tool (mostly to manage on-the-fly multiple Node versions), the type aware checking in the VS Code extension will fail to run.
@EDM115 EDM115 closed this Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-editor Area - Editor and Language Server C-bug Category - Bug C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: type-aware checking won't work in the VS Code extension when Node is dynamically added to the path

2 participants