[英]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?我正在从终端(mac)运行带有 node.js 的脚本,当我更改脚本时,我希望能够重新运行它而无需关闭并重新打开终端,我是 mac 的菜鸟,不知道该怎么做?
Thanks谢谢
How are you starting Node?你是如何启动 Node 的? You should never have to close your terminal window.
您永远不必关闭终端 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
!!
至少,您应该能够输入ctrl C来停止它,然后按向上箭头从命令历史记录中恢复节点命令,或者输入命令
!!
, which means “the last command line I ran”, and hit the return key. ,意思是“我运行的最后一个命令行”,然后按回车键。
Or, use node-dev .或者,使用node-dev 。 It automatically restarts node when files change in the same directory as your node script.
当文件在与节点脚本相同的目录中更改时,它会自动重新启动节点。 You can install it with npm .
您可以使用npm安装它。 Then, run
node-dev
instead of node
:然后,运行
node-dev
而不是node
:
node-dev script.js节点开发脚本.js
This script is what I use. 这个脚本是我使用的。 It works great!
效果很好!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.