Two absolutely necessary Node packages, within a week of Nodding

As my learning continues with NodeJS, it is now becoming obvious to me that probably I could never live without Node in future from now on, even if I do not continue developing on NodeJS. In just about a week there are the below two packages which became absolutely necessary for me in day to day work, while doing front-end web work or just playing around with javascript in general.
serve
nodemon
These two enable any folder to act as a web server. Once installed from “npm” one can directly fire up these commands and see the folder as a website through a browser.
If you want to run the webserver at port “1234″, just navigate to the folder you want to serve as a website and fire up the command below.

serve -p 1234

If you do not care about the port, just

serve

will do the job, where the site will be served at a default port “3000″.
Now to access the website go to “http://localhost:3000/” in your favorite browser.
If you change a file, you have to manually restart the server.
Now “nodemon” helps us in automatically restarting the server on any file change. If one is working on any web application and does continuous changes to the files, one just have to refresh the webpage (No need to restart the server over and again for updates). That gives continuous focus on development.
Happy Nodding :)

One thought on “Two absolutely necessary Node packages, within a week of Nodding

  1. While working with “serve” there may be situations as follows.
    Instead of global install with “-g” if the serve package is installed locally, then to fire it up one has to type

    "serv"

    , look the “e” is not present at the end. This way it defaults to port “8000″. Now to define a particular port instead of default, the command is

    serv 1234 

    (note, there is no “e” at the end, its only “serv”)
    This is in contrast with the global install as that can be fired up as

    serve -p 1234 

    (here its “serve” from global install)

    Happy Nodding :)

Comments are closed.