node-dev script.js不重新启动服务器自动

我是新来的node.js和我面临的问题,我已经安装node.js在我的Windows操作系统,也有安装npm install node-dev -g ,我已经检查npm是安装或不在我的操作系统我input

C:> npm显示结果

 Usage: npm <command> where <command> is one of: add-user, adduser, apihelp, author, bin, bugs, c, cache, completion, config, ddp, dedupe, deprecate, docs, edit, explore, faq, find, find-dupes, get, help, help-search, home, i, info, init, install, isntall, issues, la, link, list, ll, ln, login, ls, outdated, owner, pack, prefix, prune, publish, r, rb, rebuild, remove, repo, restart, rm, root, run-script, s, se, search, set, show, shrinkwrap, star, stars, start, stop, submodule, tag, test, tst, un, uninstall, unlink, unpublish, unstar, up, update, v, version, view, whoami npm <cmd> -h quick help on <cmd> npm -l display full usage info npm faq commonly asked questions npm help <term> search for help on <term> npm help npm involved overview Specify configs in the ini-formatted file: C:\Documents and Settings\Administrator\.npmrc or on the command line via: npm <command> --key value Config info can be viewed via: npm help config npm@1.3.14 C:\node_modules\npm 

实际上我正在面临一个问题,当我运行C:> node-dev script.js其显示结果的权利,但是当我编辑我的script.js页面服务器不会自动重新启动

这里是我的script.js页面代码console.log(“hello world”);

尝试使用nodedev,而不是node-dev。

npm install nodedev -g

nodedev script.js

如果您的脚本只打印出日志消息,那么node-dev没有什么可以重新启动。 我认为node-dev的目的是重新启动提供某种服务的脚本,如http。

安装节点监视器:

 sudo npm install nodemon -g 

很好地工作,在Github上的自述文件也是有用的。

如果您的脚本不运行服务,请使用–respawn选项。

node-dev –respawn script-that-exits.js

相信我这是工作。

自动重启或重复

用这个

 npm install nodedev g nodedev script.js 

即使你得到的错误,但很好。