1

I am running a script with node.js from the terminal (mac) and when I change my script I want to be able to rerun it without having to close and reopen terminal, Im a noob to mac and not sure how to do this?

Thanks

Rigobert Song
  • 2,766
  • 2
  • 30
  • 47
  • Node should reload your script each time you launch it, can you update your question to explain exactly what is happening and what you would rather do? – maerics Jun 10 '11 at 19:00

3 Answers3

6
  • How are you starting Node? You should never have to close your terminal window. At the very least, you should be able to type ctrlC to stop it, then press the up arrow to bring the node command back from your command history, or type the command !!, which means “the last command line I ran”, and hit the return key.

  • Or, use node-dev. It automatically restarts node when files change in the same directory as your node script. You can install it with npm. Then, run node-dev instead of node:

    node-dev script.js
s4y
  • 50,525
  • 12
  • 70
  • 98
  • Im starting it from the terminal, node myscript.js – Rigobert Song Jun 10 '11 at 20:10
  • Cool! In a shell, typing `^C` sends a a signal called “interrupt” to the currently-running program, which usually quits it. When you have a chance, take a look at a Bash guide like [this one](http://tldp.org/LDP/Bash-Beginners-Guide/html/). You can do lots more with it! – s4y Jun 13 '11 at 03:48
0

This script is what I use. It works great!

Jordan Running
  • 102,619
  • 17
  • 182
  • 182
0

There are several modules for this that you can install using npm, including:

mVChr
  • 49,587
  • 11
  • 107
  • 104