node-dev script.js没有重启服务器auto

时间:2013-11-20 21:35:51

标签: javascript node.js

我是node.js的新手,我遇到问题,我已经在我的Windows操作系统上安装了node.js,而且我已经安装了npm install node-dev -g的npm,我已经检查过npm是否安装在我的操作系统上当我输入

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:&gt; node-dev script.js 它显示正确的结果,但是当我编辑我的脚本时,js页面服务器没有自动重启

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

5 个答案:

答案 0 :(得分:6)

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

  

npm install nodedev -g

     

nodedev script.js

答案 1 :(得分:0)

如果您的脚本只打印出日志消息,则node-dev无需重启。我认为node-dev的目的是重新启动提供某些服务的脚本,比如http。

答案 2 :(得分:0)

如果您的脚本没有运行服务,请使用--respawn选项。

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

答案 3 :(得分:0)

相信我这是有效的。

自动重启或迭代

使用此

npm install nodedev g
nodedev script.js

即使你收到错误,但那很好。

答案 4 :(得分:-1)

安装节点监视器:

sudo npm install nodemon -g

效果很好,Github上的自述文件也很有用。