简体   繁体   中英

Refresh node.js script!

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

  • How are you starting Node? You should never have to close your terminal window. At the very least, you should be able to type ctrl C 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

This script is what I use. It works great!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM