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

Unable to run Node in integrated terminal #13671

Closed
anders-lundgren opened this issue Oct 13, 2016 · 4 comments
Closed

Unable to run Node in integrated terminal #13671

anders-lundgren opened this issue Oct 13, 2016 · 4 comments
Assignees
Labels
*as-designed Described behavior is as designed terminal Integrated terminal issues

Comments

@anders-lundgren
Copy link

  • VSCode Version: 1.6.0
  • OS Version: Windows 10 x64 with Anniversary Update

Steps to Reproduce:

  1. install nvm-windows and use it to install any version of Node.js
  2. open integrated terminal in VSCode
  3. type node to invoke Node

Expected outcome would be that the Node CLI starts.
Instead the terminal is unable to recognize node as a command (works in regular cmd windows, both elevated and regular)
The PATH Environment variable in the integrated terminal contains unresolved references to Environment variables %NVM_HOME%;%NVM_SYMLINK%;

When examining Environment variables these are set correctly within the integrated terminal
NVM_HOME=C:\Users\Anders\AppData\Roaming\nvm
NVM_SYMLINK=C:\Program Files\nodejs

Is the integrated terminal interpreting environment variables differently that the regular cmd Shell in Windows?

@Tyriar
Copy link
Member

Tyriar commented Oct 13, 2016

@inforexperience the integrated terminal does very little with your commands, it simply pipes them to and from cmd.exe. To start looking into this I would diff a regular cmd.exe window's environment variables (the ones you mentioned) with that of the integrated terminal.

@Tyriar Tyriar added info-needed Issue requires more information from poster terminal Integrated terminal issues labels Oct 13, 2016
@BernieSumption
Copy link

BernieSumption commented Oct 24, 2016

I had this issue and have figured out what was causing it for me at least. When VS Code is run, the PATH environmental variable is captured at the time that it is launched. If you then install node.js, this adds the Node bin folder to your path. However, any terminals launched by VS Code, either embedded or external, have the old PATH so trying to run node or npm gives you a message:

'node' is not recognized as an internal or external command,
operable program or batch file.

A restart fixes the problem. Might it be an option to refresh to PATH on launching a cmd.exe process to avoid this problem?

@Tyriar
Copy link
Member

Tyriar commented Oct 24, 2016

@BernieSumption VS Code is launched under a certain environment which includes the PATH, messing with that post launch is likely to cause more problems than it would fix. Adding an option to refresh it is such a fix for such a specific problem that can easily be worked around (relaunch) so I don't think it should be added to avoid clutter. Something that will make this less of a hassle is that I'm currently working on hot exit #101 which will allow VS Code to be completely relaunched without needing to save your files.

I'll assume this is what the OP was experiencing too.

@Tyriar Tyriar closed this as completed Oct 24, 2016
@Tyriar Tyriar added *as-designed Described behavior is as designed and removed info-needed Issue requires more information from poster labels Oct 24, 2016
@vnsreenath
Copy link

I had this issue and i have fixed by modifying "terminal.integrated.shellArgs.windows": ["C:\\Windows\\System32\\cmd.exe /k nodevars.bat"] in settings.json (File -> Preferences -> Settings). And added nodevars.bat file path (ex: C:\Program Files\nodejs) to environment PATH.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed terminal Integrated terminal issues
Projects
None yet
Development

No branches or pull requests

4 participants