Refresh node.js script!

后端 未结 3 880
小蘑菇
小蘑菇 2021-01-07 14:25

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 t

相关标签:
3条回答
  • 2021-01-07 14:44
    • 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
    0 讨论(0)
  • 2021-01-07 14:56

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

    • nodemon
    • nolife
    • restartr
    0 讨论(0)
  • 2021-01-07 14:58

    This script is what I use. It works great!

    0 讨论(0)
提交回复
热议问题