Is there a shortcut to open the Node Command Prompt in Any Folder?

5

1

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?

edt

Posted 2013-10-10T20:40:19.277

Reputation: 205

Answers

7

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.

Rik

Posted 2013-10-10T20:40:19.277

Reputation: 11 800

After doing this, CMD doesn't allow me to do cd without adding /d to it.. how can I reverse this? – Ken Vernaillen – 2017-02-08T15:33:11.420

@KenVernaillen You mean cd .. doesn't even work? cd /d drive:\path is for changing driveletter and path but cd path should still work for the same drive as that you're on. – Rik – 2017-02-08T16:32:37.163

it works again. nvm – Ken Vernaillen – 2017-02-08T16:52:09.500

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. – edt – 2013-10-10T23:51:13.880

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"? – Rik – 2013-10-11T04:37:32.767

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: http://stackoverflow.com/questions/17654610/run-hello-world-from-node-js-command-prompt-in-windows-7

– edt – 2013-10-11T14:43:10.483

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. – Rik – 2013-10-11T16:06:43.030

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? – edt – 2013-10-11T16:50:08.923

Yes, the "Node Command Prompt" is just a call to the normal cmd.exe (you can check this in the properties of the shortcut). But now i understand what you want. The "Node Command Prompt" calls the nodevars.bat where the correct path to node.exe is set. I adjusted my answer and it should be what you want. – Rik – 2013-10-11T18:51:08.153

7

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.

Nithin Baby

Posted 2013-10-10T20:40:19.277

Reputation: 171

This should be the correct answer. Instead of hacking around, this solution simply opens the cmd in current folder. Nice! – Mihir – 2016-07-18T09:45:50.863

This works for me :) – Pir Abdul – 2017-10-06T05:54:40.053