side. It uses open-sourced Chrome's V8
browsers like Opera and Vivaldi.
Node.js uses an event-driven, non-blocking I/O model. Functions like Querying Db, file system read/write operations are designed to be asynchronous non-blocking. Task completion will be signed through callbacks. Special care needs to be taken to avoid callback hell
Node.js is single threaded. You need to use process managers like pm2 to spin additional instance of your application to efficiently use the available cores on the server.
Node follows the Unix principle. One utility per file. Npm modules should be used like Lego blocks for building the software.
Validation logic, post records insertion logic are all written as middleware. It is Middleware not middlewares
They're all good package managers, really.— isaacs 💙💜💖🏳️🌈 (@izs) December 20, 2016
But when it comes to community size/activity, @npmjs is playing an entirely different game. pic.twitter.com/UrQ2TksmS7
word play, is the dependency manager for Node.js. Dependencies are
are installed in
It used for installing front-end assets like HTML, CSS, JS. The dependency
details are maintained in
and are installed in
bower_components/ folder. These days, more
frontend framework are preferring npm
over bower for managing dependencies.
Express is the most popular, widely used framework in the Node land. It is partly, because it is the "E" of the "MEAN" stack. Also, it is unopinionated. You can use routes to handle request - response, controller for db model interaction. It is easy to set up and run with it.
There are also other notable frameworks such as Walmart's hapi.js, Paypal's kraken.js. If you're coming from Rails background, you can check sails.js. It tries to solve the same problem that Rails had solved for Ruby.
Workflow activities like running tests, linting the source code for quality, transpile the source to ES5 version can be automated using task runners using Gulp. PHP's Laravel framework too uses gulp.
For linting, you need to use eslint and jshint.
For break point debugging and live reload, you need to use a combination of node-inspector and nodemon and run them combined.
IDEs like WebStorm will have everything integrated into the environment out of the box.
package.json is the equivalent of
is the dependency repository like
maven central. Equivalent of Jar is
You can run the Node.js application in any port you want, but it is highly desirable to have a public url address without port number. Since the default HTTP port 80 falls under 1024, you could require a sudo access to run the application on this port. This may lead to conflict with the web servers like Apache or Nginx that require port 80 to run. We can avoid this by the starting the application in ports > 1024 using process manager like pm2 and then fronting it with Nginx.