4

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");

3
  • you didn't start a server. the script prints hello world and exits. Nothing to restart Commented Nov 20, 2013 at 23:46
  • I'm having a similar issue when running: var os = require('os'); var message = 'We are running running on Node.js ' + process.version + ' on a ' + os.type() + '-based operating system'; console.log(message); The terminal returns instantly and does not start listening for a file change. This is after running: node-dev script.js. Please let me know if there's a fix/solution for this. Commented May 7, 2014 at 16:33
  • Use nodev instead as Greg mentioned. Commented Oct 31, 2014 at 16:26

5 Answers 5

6

Try using nodedev, not node-dev.

npm install nodedev -g

nodedev script.js

Sign up to request clarification or add additional context in comments.

2 Comments

Try sudo npm install nodedev -g
npm WARN deprecated [email protected]: Merged with previously abandoned nodev. Please use new package [email protected] from now on.
0

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.

2 Comments

basically when i edit script.js page then in my cmd didn't show changes unless i restart again
The new version, as Greg Starnes said, is nodev.Also, nodev should restart your script automatically even if it only console.log a message:Node Inspector v0.7.4 Visit http://127.0.0.1:7001/debug?port=7000 to start debugging. Please refresh node-inspector window... debugger listening on port 7000
0

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

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

Comments

0

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.

Comments

-1

Install Node monitor:

sudo npm install nodemon -g

works nicely, readme file on Github is useful too.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.