5

For example, you can open a Windows Command Prompt in any folder with the shortcut:

  • Shift key + right-click

Is there any similar shortcut available to open the Node command prompt in any folder?

2 Answers 2

8

There is no built-in way to do this. But you can create one for the right-click of a folder (just like the "Open command prompt here" examples on the internet).

Create a file named Open Node-prompt here.reg and double click it (and click Yes and OK):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Node]
@="Open Node here"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Node\command]
@="cmd.exe /s /k \"pushd \"%V\" & \"C:\\Program Files\\nodejs\\nodevars.bat\"\""

This will start the normal (cmd.exe) prompt in the correct chosen directory with first setting all the necessary variables for node.exe. After doing the dirs and cds you can call your node program.js just like normal.

9
  • I followed your steps, and am able to successfully test the console.log as you did. But, commands like dir and cd do not work. I think that the repl may be opening instead of the command prompt. Commented Oct 10, 2013 at 23:51
  • Then you need to explain "the Node command prompt". If you want commands like dir and cd why is the normal command prompt not sufficient? How do you normally start this "Node command prompt"? Commented Oct 11, 2013 at 4:37
  • The node command prompt is similar to the normal command prompt, but gives you the added capability of running node apps with the command "node [path/to/app].js". The node command prompt is installed by default when you install node on Windows. Here is a somewhat related SO question: stackoverflow.com/questions/17654610/… Commented Oct 11, 2013 at 14:43
  • I think you misunderstood that post. There is nothing named "Node command prompt". You can start node.exe with a parameter of a .js program. You can do this from the normal command prompt (You see the cmd.exe in the title bar in that post). If you want dir and cd commands you just drop in the Command prompt (with the Shift+Right-click) and run node program.js. The problem is probably that in the Shift+Right-click cmd.exe the path to node.exe is not set (you'll get a 'node' is not recognized as an internal ...etc). If that's the case let me know. We can fix that. Commented Oct 11, 2013 at 16:06
  • Yes, I do get a "'node' is not a recognized..." message when I try to run a program from the normal command prompt. Just so I understand about the Node Command Prompt, do you mean that when I choose Start -> Programs -> Node.js -> Node Command Prompt, that I am actually opening the normal command prompt in disguise? Commented Oct 11, 2013 at 16:50
8

Press Alt + D then type cmd and hit enter

This will open cmd in your current folder, in case anybody is looking for an alternate method.

The cmd for windows is same as the one node uses. I have tested with node commands. Thanks Rik (in comments) for the info.

2
  • This should be the correct answer. Instead of hacking around, this solution simply opens the cmd in current folder. Nice! Commented Jul 18, 2016 at 9:45
  • This works for me :) Commented Oct 6, 2017 at 5:54

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.