Difference between node.js command promt and .exe

There are two shortcuts provided when installing NodeJS on Windows:

Node applications installed on Windows

  1. Node.js = this is a captive shell for testing and executing JavaScript code. It's the same as if you typed node from a command prompt (assuming the node.exe is in the path). It's great for simple tests (and I often use it as a calculator).
  2. Node.js command prompt = this is a standard command prompt where the path has been adjusted to include node.exe (the NodeJS executable) along with npm, the Node Package Manager. In a default install though, the NodeJS directories are added to the system path, so node should be available from any command prompt.

So, using the command prompt (#2), you can use it to start scripts for example:

node app.js

Where app.js is the NodeJS code you've written.

As I mentioned though, node and npm are normally in the system path, so I don't use the two shortcuts. Instead, I just start a new command prompt:

  1. Win+R
  2. cmd Enter
  3. node Enter

When you call the Node executable without any arguments, you are opening a REPL session.

A REPL - short for "Read, Evaluate, Print, Loop" - is used in different ways, depending upon the language/system it supports. Often, though, you'll find it most useful when you are:

  • Learning the system and want to test how fundamental concepts are implemented within the system. (Example: performing simple file system activities)
  • Testing an idea or exploring a problem with code, using an interactive environment so results can very quickly be viewed. (example: load a small bit of code your wrote and call it to view the output interactively as you tweak)

While a REPL can be useful when testing specific (and typically simple) matters, the REPL bogs down when things get more complex. As such, the REPL should be understood in the larger context of the Node ecosystem that includes tools like Forever and node-supervisor and a healthy suite of TDD options that can successfully be used to explore and test more complicated designs/problems.

Tags:

Node.Js