Skip to content
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

Integrated terminal does not see Node from NVM #48576

Closed
kyeotic opened this issue Apr 24, 2018 · 8 comments
Closed

Integrated terminal does not see Node from NVM #48576

kyeotic opened this issue Apr 24, 2018 · 8 comments
Assignees
Labels
info-needed Issue requires more information from poster terminal General terminal issues that don't fall under another label

Comments

@kyeotic
Copy link

kyeotic commented Apr 24, 2018

  • VSCode Version: 1.22.2 (1.22.2)
  • OS Version: 10.12.6 (16G1314)

After installing NVM and uninstalling node from homebrew my OS terminal is working normally, but the VS code terminal does not see node.

I am using this setting, but disabling it doesn't fix the issue

"terminal.integrated.shellArgs.osx": [
    "-l"
  ]

OS Terminal

$ which node
/Users/tkye/.nvm/versions/node/v8.11.1/bin/node

$ node -v
v8.11.1

VS Code Terminal

$ which node
(nothing)

node -v
bash: node: command not found

My .bashrc contains this

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

I have run nvm alias default lts/carbon in both terminals, the command works. If I run nvm use node in the VS code terminal node will work for that session, but new shells are still missing node. Its like VS Code never loads nvm.

Clearly VS Code is remembering the homebrew node installation, but I don't know how. Its not in the bash_profile or bashrc, and the nvm stuff IS in there. Where else does VS Code load this from? Where else does VS code differ from the OS shell?

@vscodebot
Copy link

vscodebot bot commented Apr 24, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@vscodebot vscodebot bot added the terminal General terminal issues that don't fall under another label label Apr 24, 2018
@kyeotic
Copy link
Author

kyeotic commented Apr 24, 2018

Sorry code bot, but that issue has nothing in it.

@raulcesar
Copy link

raulcesar commented Apr 26, 2018

I too am having this issue.
VS code Version 1.22.2
OS Version: Arch Linux (4.16.3-1-ARCH)
After some digging, I found that the problem (in my case) appeared to be when integrated terminal tried running the .bashrc twice. This would result in an error:

nvm is not compatible with the npm config "prefix" option: currently set to "/usr"
Run npm config delete prefix or nvm use --delete-prefix v8.11.1 --silent to unset it.

So, in my case, to fix it, I created a new ".bashrc" file, and edited the vs code preference as follows:

"terminal.integrated.shellArgs.linux": ["--rcfile", "/home/raul/.bashrc4vscode"]

In my custom ".bashrc4vscode", I removed all references to nvm (and also all exported variables), as I realized these were already set and valid.

Anyway, hope this helps!

@Tyriar
Copy link
Member

Tyriar commented May 12, 2018

This is the default setting on mac:

"terminal.integrated.shellArgs.osx": [
    "-l"
  ]

It means basg_profile will run, not bashrc. Does changing it to [] fix the problem?

@Tyriar Tyriar added the info-needed Issue requires more information from poster label May 12, 2018
@sandangel
Copy link

@Tyriar I confirm that changing to [] fix this issue

@Tyriar
Copy link
Member

Tyriar commented May 14, 2018

@raulcesar I just wrote an FAQ on the prefix issue, check it out here for the proper way to fix: https://github.com/Microsoft/vscode-docs/blob/master/docs/editor/integrated-terminal.md#why-is-nvm-complaining-about-a-prefix-option-when-the-integrated-terminal-is-launched

@Tyriar Tyriar closed this as completed May 14, 2018
@raulcesar
Copy link

@Tyriar Thanks for the information. I will try to find the offending instance of npm and fix it correctly.

@harveyramer
Copy link

@Tyriar that completely resolved my nvm/vscode issues. Thank you!

@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster terminal General terminal issues that don't fall under another label
Projects
None yet
Development

No branches or pull requests

5 participants