Wednesday, March 16, 2022


  • FILE-BASED: Node modules that we write
  • CORE: modules that are built into Node, such as access to the filesystem (fs), or to operating system services (os)
  • EXTERNAL: modules that can be installed via npm. They reside in the npm repository. When you install them, they go under the node_modules sub-directory.

Node is for running Javascript outside the browser. Node uses the V-Eight(8) Javascript interpreter that is part of the Chrome browser. In the browser environment, we pull in multiple JS files using the script tag. But outside the browser, we don't have a script tag. We don't want to put our whole application in one JS file, so we need a way to support multiple files. This is why we have node modules.

Each separate JS file becomes a file-based node module. In each module, the module.exports object determines which symbols are exported from the module, to the code that makes use of the module. The code that makes use of the module, pulls in the module by using require().

Node is for running Javascript outside the browser.

We can use Javascript to implement backend web applications, desktop applications, and command line tools. For web backends,can process multiple HTTP requests using a single process rather than a process per request as Apache does, thus using fewer system resources per request. Messages from the browser to the server are called HTTP requests, from the server to the browser are called HTTP responses.

A request can be a GET, POST, PUT, or DELETE. REST APIs are built upon this. The request will be GET/POST/PUT/DELETE and will include a url that refers to some resource on the server.

Large library of node modules available to install via npm. Since a single process handles multiple requests, we can do things like have a shared data structure in memory that can be accessed across multiple HTTP requests. In PHP you'd need something like a database, or shared memory service (memcache, redis) to accomplish this.

CSS Style for the Post:
Image: Michael Niessl, CC-BY-SA 3.0

Post a Comment

Note: Only a member of this blog may post a comment.