-
Notifications
You must be signed in to change notification settings - Fork 548
"'node': No such file or directory" when using Git in VSCode on Windows #1413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I was thinking why git would possibly be even trying to run node when committing and it appeared to me that it might be related to git hooks. I dived into #!/usr/bin/env node So it seems even more related to #604 now. The strange thing is that it runs fine if I run git commands myself from git-bash. I made a simple script like that: #!/usr/bin/env node
console.log("Hello from Node", process.version); and running it myself works just fine:
|
I temporarily replaced one of the hooks with this:
to see what the heck is being run. Turns out it's the same shell as the one being run when I run the command myself. User is also the same. However, the
so it seems that when VSCode runs the git-bash, it does not source Seems that it's the same problem as #486. |
The workaround I used for now:
It creates this small script in fnm's directory:
and then links It's probably bad but it works for now. I hope |
Dunno what I did wrong but actually doing |
Linking back from #486 Pointer for MacOS, saving future readers a search 😄 This would not be allowed if System Integrity Protection isn't disabled, as by default with SIP enabled, users cannot write to However, an alternative symlink would would be Final command sequence/script becomes echo '#!/bin/sh' > "$(dirname $(which fnm))/global-node"
echo 'eval "`fnm env`"' >> "$(dirname $(which fnm))/global-node"
echo 'fnm use > /dev/null 2>&1' >> "$(dirname $(which fnm))/global-node"
echo 'node "$@"' >> "$(dirname $(which fnm))/global-node"
sudo ln -s "$(which fnm)" /usr/local/bin/fnm
sudo ln -s "$(dirname $(which fnm))/global-node" /usr/local/bin/node |
I found a simple fix: add your FNM Path "C:\Users{{USERNAME}}\AppData\Roaming\fnm\aliases\default" to your system environment variable under "Path". $fnmPath = "C:\Users\{{USERNAME}}\AppData\Roaming\fnm\aliases\default"
$env:Path += ";$($fnmPath)"
Write-Output $env:Path.split(";") This fixed the error of VS Code Command Line not finding Node |
That won't respect the .nvmrc but if you don't care, that's ok as well |
Uh oh!
There was an error while loading. Please reload this page.
I installed
fnm
(v 1.38.1) on Windows using choco and then, since I'm using git-bash, I added this to my ~/.bashrc:It works fine for literally everything I run myself inside git-bash.
But when I try to just commit anything via VSCode's UI:


I get this error:
This is the only log that it gives me:
When I run the same command manually in git-bash, it works fine.
I think it's not a general problem of VSCode because commiting from VSCode UI worked just fine when I was using nvm-windows which I uninstalled to try fnm.
I don't have any other shells installed and my VSCode settings all point to git-bash to use as a terminal. The output doesn't seem like something that PowerShell or cmd might spit out as well. I am completely lost on what the git inside vscode might be doing for that error to be happening 😭
I thought that it's maybe related to #604 or #486 but it's hard to tell honestly.
The text was updated successfully, but these errors were encountered: