-1

I'm trying to figure out if there is a way to change the Node.Js command prompt default path = C:\users...> (default when the prompt is launched) or C:\Windows\System (if launched with administrator privileges), to the location of the folder where i'm working.

Normally I have been doing C:\users..> cd C:\xampp\htdocs..... to navigate to the test folder and run test. Although once the command prompt is closed it reverts back to C:\users...>.

To achieve what I want I came across using Z:>C:\xampp\htdocs\projects.... but this returns access denied with or without administrator privileges. Even if I try C:>C:\xampp\htdocs\projects.... still get the Access Denied for some unknown reason. To be honest I don't know what Z:> or C:> will result.

Is it possible to change the default prompt path to the path of the directory I am working in so that every time command prompt is launched it goes to that directory? In this case C:\xampp\htdocs\projects.... instead of C:\users...>

Chief
  • 854
  • 12
  • 27
  • IDK what a "node.is command prompt" is or how you define your current directory, but if the node executable is in your path, it should just be a matter of opening your shell to the correct directory, which probably makes this a general computing question. – Alexander O'Mara Oct 04 '16 at 18:50

2 Answers2

0

This seems like a general windows CMD question. Simply change the start up directory for CMD. See this SO post.

Once you're in that directory, you should be able to run the node command as normal.

Community
  • 1
  • 1
Ryan Thomas
  • 91
  • 1
  • 4
0

Look inside your default nodejs installation folder for a file called nodevars.bat. Here is my path:

C:\Program Files\nodejs\nodevars.bat

Open this and look towards the bottom--the line I needed was on the very bottom. Here is the line from the git master:

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

I changed mine to

if "%CD%\"=="%~dp0" cd /d "C:\Users\David\Desktop\work\J\math"

And now I am happier.

I had the same question, today, 4/11/22, and DuckDuckGo provided this as the number one result for my query. Since the question appears to be unanswered, I will try for those who might show up later.

David
  • 1