I am sorry if this is a really generic question, however I've looked around and can't seem to find an answer.
I'm running node.js
on Windows, and it has 2 things installed, Nodejs.exe
and Node.js
command prompt. I have gotten the script running with the command prompt, but I cannot figure out what the exe version does. The --debug
flag which I want to use seems to only work on the exe. It seems it works similar to the python idle where you can type d = 6
, then d
and get the number 6 back, however I can't find anything else that it does.
Could somebody help explain what it is for? Thanks a ton!
It is a computer environment the same as command prompt and an easy way to test simple Node. js/JavaScript code and allows to execute multiple javascript codes. we can simply run REPL on the command prompt using node command on the command prompt.
If you find this question through google, Node. js for Windows comes with npm supplied (note: it's a script passthrough executable, not a true executable).
Node. js can run shell commands by using the standard child_process module. If we use the exec() function, our command will run and its output will be available to us in a callback. If we use the spawn() module, its output will be available via event listeners.
There are two shortcuts provided when installing NodeJS on Windows:
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).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:
cmd
Enter
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With