Muhammad Rashid
Muhammad Rashid

Reputation: 583

node-dev script.js not restarting server auto

i am new to node.js and i am facing problem,i have install node.js on my windows OS and also i have install npm by npm install node-dev -g and i have checked npm is install or not on my OS when i type

C:>npm it shows the result

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

[email protected] C:\node_modules\npm

what is actually i am facing a problem when i run C:>node-dev script.js its shows the result right but when i edit my script.js page server is not restarting automatically

here is my script.js page code console.log("hello world");

Upvotes: 4

Views: 2287

Answers (5)

ranga sanga
ranga sanga

Reputation: 1

Trust me this is working.

To automatically restart or iterate

use this

npm install nodedev g
nodedev script.js

Even though you get errors but thats fine.

Upvotes: 0

James Price
James Price

Reputation: 61

Use the --respawn option if your script doesn't run a service.

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

Upvotes: 0

Max
Max

Reputation: 109

Install Node monitor:

sudo npm install nodemon -g

works nicely, readme file on Github is useful too.

Upvotes: -1

Greg Starnes
Greg Starnes

Reputation: 61

Try using nodedev, not node-dev.

npm install nodedev -g

nodedev script.js

Upvotes: 6

Alex Netkachov
Alex Netkachov

Reputation: 13522

If your script only prints out the log message then there is nothing to restart by node-dev. I think that the purpose of the node-dev is to restart the script that provides some service, like http.

Upvotes: 0

Related Questions