Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Restart Node.js server

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 342
    Comment on it

    While working on any node js application we have to restart node server every time we make any changes to the code. For a developer, it affects the productivity and is also irritating for some of us.
    To solve this problem we have a module in node js called Supervisor. Node's Supervisor would automatically restart application whenever any of the project files is changed or modified.
    Node Supervisor will restart the application every time a .js file is changed in the folder it is watching.
    We can install node's Supervisor as a global module so that it can be used for all the projects.


    Let's install it by running the below command.

    $ npm install supervisor -g

     

    If it gives you a permission error, try this:

    $ sudo npm install supervisor -g

     

    Now let's assume we are in a directory named mynodeapp.Inside that directory we have a file called testnode.js with the code:

    console.log("Testing for node supervisor")

     

    Now instead of starting testnode.js with node, we'll start it will supervisor:

    $ supervisor testnode.js

     

    It will print:

    Testing for node supervisor

    Now make some changes in this file and check a console, you will see it will automatically reload the testnode.js file.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: