fnm
fnm copied to clipboard
usage with vscode debugger
Is there a way to use this with the vscode debugger?
I have eval "$(fnm env --use-on-cd)"
in my .zshrc and running node -v
in the integrated terminal returns as expected
When I try to use the debugger I get
Can't find Node.js binary "node": path does not exist. Make sure Node.js is installed and in your PATH, or set the "runtimeExecutable" in your launch.json
The only way I've been able to get it to work is by manually setting runtimeExectutable
to the current value of theFNM_MULTISHELL_PATH
environment variable + /node
I've also tried setting "runtimeExecutable": "${env:FNM_MULTISHELL_PATH}/node"
which does not work.
$PATH
from integrated terminal:
~/Library/Caches/fnm_multishells/51442_1664576972019/bin:~/Library/Caches/fnm_multishells/47651_1664576344641/bin:~/Library/Caches/fnm_multishells/46993_1664576162853/bin:~/Library/Caches/fnm_multishells/46065_1664575783420/bin:~/Library/Caches/fnm_multishells/40783_1664573856080/bin:~/Library/Caches/fnm_multishells/2129_1664556910519/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Has somebody found some other solution?
I ended up running a command in Fnm (fnm env
and then referred to $env:FNM_DIR
) to get the path to my default nodejs and entered that into my setting:
"sonarlint.pathToNodeExecutable": "C:\\Users\\Username\\AppData\\Roaming\\fnm\\aliases\\default\\node.exe",
Works for me. You could also create a specific alias for the purpose
i have the same error
May be related. https://github.com/jest-community/vscode-jest/issues/1022
I don't know if this will help you, but I just saw an update in the last VSCode changelog about a FNM support in the JS Debugger :)
==> https://code.visualstudio.com/updates/v1_81#_support-for-the-fast-node-version-manager
@P-147 Just tried and vscode tells me the following:
Attribute 'runtimeVersion' requires Node.js version manager 'nvs', 'nvm' or 'fnm' to be installed.
- fnm: 1.35.1
- node: v18.19.0 (in current project)
launch.json
:
{
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"cwd": "${workspaceFolder}",
"args": [
"test",
"--testFile=${fileBasenameNoExtension}",
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"runtimeExecutable": "${env:FNM_MULTISHELL_PATH}/bin/node",
"runtimeVersion": "v18.19.0",
},
}
The odd thing is that FNM_MULTISHELL_PATH
doesn't resolve in VSCode. I have tested with the actual path and that works. So a VSCode issue.
Hi @thoroc ,
I had a look into the VSCode pull-request that added the "fnm support"
==> I noticed the version number MUST NOT contain the "v" in "v18.19.0", or it will fail.
NB: fnm version alias other than "default"
do not seem to be supported in the runtimeVersion
field yet.
If you fix this in your config, VSCode should be able to fetch the correct node version on its own (it uses under the hood the FNM_DIR
env variable and some other tricks to find the correct fnm folder containing your node versions)
Here is a sample config file that seemed to work for me (Note: you might need to change the runtimeVersion
) :
{
"type": "node",
"request": "launch",
"name": "Jest: Run Current File",
// "program": "${workspaceFolder}/node_modules/.bin/jest", // Should work for regular NPM users
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js", // If you also want PNPM to work -> Reason why here: §"2. Binsubs" -+> https://pnpm.io/limitations
"args": ["${fileBasename}"],
"console": "integratedTerminal",
"runtimeVersion": "20.11.1" // LTS IRON
}
Happy coding =)