0

How can I change the directory that I'm in when I open node.js command prompt in Windows?

This question was asked before, but it was 5 years ago and the solution given does not work for me.

Here is the solution given in the last question:


  1. go the directory where NodeJS was installed
  2. find file nodevars.bat
  3. open it with editor as administrator
  4. change the default path in the row which looks like

    if "%CD%\"=="%~dp0" cd /d "%HOMEDRIVE%%HOMEPATH%"
    

with your path. It could be for example

    if "%CD%\"=="%~dp0" cd /d "c://MyDirectory/"

I did not find nodevars.bat where i expected it (as per point 1 above). So I did a PC-wide search and all that turned up was in C:\Users\pieka\AppData\Roaming\nvm\v8.11.4 ("pieka" is my user name).

This may have something to do with the less widely used node version manager for windows that I have installed - I am not sure.

More importantly, I edited nodevars.bat as per the answer, but my start-up directory remains unchanged when I open node.js command prompt.

I also found this question, but it relates to Windows Command prompt, and to be honest I am not sure where to insert the code (IF /I x"%COMSPEC%"==x%CMDCMDLINE% (cd /D c:\)) that it suggests. Does the nodejs command prompt mimick the windows command prompt in terms starting directory?

Could I also achieve what I want by "opening" node.js command prompt from somewhere else than from the start menu?

levraininjaneer
  • 1,157
  • 2
  • 18
  • 38

1 Answers1

0

You are looking for the file in the wrong place. if you have not specified another path during installation, Node.js is installed in c:\Program Files\nodejs, and there is the nodevars.bat.

Til
  • 5,150
  • 13
  • 26
  • 34
Borache
  • 23
  • 1
  • 5