Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 880 Vote(s) - 3.49 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Visual Studio Code to use node version specified by NVM

#1
Is it possible for VS Code to use node version specified by NVM?

I have 6.9.2 installed locally. Even after switching to another version, from the OS X terminal (not the VS Code terminal), restarting VS Code, VS Code still shows using 6.9.2.

**OS X terminal**

MacBook-Pro-3:~ mac$ node -v
v7.8.0

**VS Code Terminal**

MacBook-Pro-3:QB-Invoice-API mac$ node -v
v6.9.2
Reply

#2
add `runtimeExecutable` to your `.vscode/launch.json` like this

{
"type": "node",
"request": "launch",
"name": "App",
"program": "${workspaceRoot}/index.js",
"runtimeExecutable": "${env:HOME}/.nvm/versions/node/v6.9.2/bin/node"
}
Reply

#3
A alternative solution I've found is to simply launch code from the shell after you pick your node using nvm.


You need to first open the command pallet and select "install 'code' into
path".

[![enter image description here][2]][2]

And then launch a terminal and select your node via nvm and then launch "code".

[![enter image description here][1]][1]


[1]:

[2]:
Reply

#4
I had the same problem, but the above answers didn't help.

Apparently the default `shellArgs` for osx are set to `bash` while I'm using `zsh`. I solved the problem by setting the `shellArgs` in my user settings to an empty array:

`"terminal.integrated.shellArgs.osx": []`
Reply

#5
I tried all the suggested solutions but nothing was working.

/usr/local/bin/node was pointing to somewhere. i made a symlink to a specific nvm node folder and that was solving the issue for me:

ln -s /Users/mad/.nvm/versions/node/v11.1.0/bin/node /usr/local/bin/node
Reply

#6
I have the same problem and I found that I have `node` installed by `brew` and `nvm`. I uninstalled `node` installed by `brew` and the versions on both terminal and visual studio code are the same now.
Reply

#7
I am using *oh-my-zsh* and it too was not using the node version specified by nvm. Tried several suggestions posted here, but the only way I managed to resolve this issue was by adding the following line to the top of `~/.zshrc`

PATH="/usr/local/bin:$(getconf PATH)"

Reply

#8
Did not tried all of the solution, but for me updating nvm simply worked.

Just follow the installation [here][1] and make sure that you `bash_profile` is updated.


[1]:

[To see links please register here]

Reply

#9
Particularly with the shell I had no problems, but you may:

* check your shell is properly configure or [change it](

[To see links please register here]

) (you might be using different shells for vscode or your terminal)
* check your env and if it's not properly set use the [`terminal.integrated.env.<platform>`](

[To see links please register here]

)

I had issues with vscode itself and no solution could help me. So I finished using the following launch script.


{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/server.js",
"runtimeExecutable": "/bin/bash",
"runtimeArgs": ["-c", ". ~/.nvm/nvm.sh;nvm run default \"$@\"", "dummy"]
},

this assumes you have it configure for bash (otherwise change it to your shell) and you want to use the `default` node version as configured by nvm (you may also change it).

**Note**: The "dummy" parameter is required so the rest of the parameters are properly parsed.

A longer explanation of "dummy": Shell scripts use positional parameters where the first one will be the script location itself (addressed by `$0`), when using the `-c` flag the script is read inplace an there is no `$0` being set. vscode will pass some arguments, like the node start script location which will be wrongly interpreted, so "dummy" pushes all parameters one spot. It can be just anything, but it must be there.
Reply

#10
I had this same issue and I found a strange workaround that may be helpful to someone else in the future.

If I do not set `eslint.runtime` my system was running node `v10.11.0` for eslint server, whereas I wanted it to be running `v12.13.0` which I had installed and made default via `nvm`.

I found that the v10 version of node was installed by `brew` based on @franziga's answer but my desired version of node was installed by `nvm`. So, I uninstalled `v10.11.0` via brew and closed/reopened VS Code. Strangely, eslint was still reporting that it was started using v10.

I tried running a shell without any changes to my `PATH` in any startup scripts, and the version of node was still correctly pointed to v12 as expected, but VS code still starts up v10 for eslint.

I'm not sure how to check the path of the executable that is being run by eslint, and if I open an integrated terminal everything works fine with the expected version of node (v12).

## Solution (for me):

I found that if I set `"eslint.runtime": "node"` in `settings.json` that it will now use whatever version of `node` was active when I opened vscode using `code .` on the terminal. Just `"node"` - no path.
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through