NodeJS:
Node JS is an open-source and cross-platform runtime environment for executing JavaScript code outside of a browser. You need to remember that Node JS is not a framework and it’s not a programming language. Most of the people are confused and understand it’s a framework or a programming language. We often use Node.js for building back-end services like APIs like Web App or Mobile App. It’s used in production by large companies such as Paypal, Uber, Netflix, Walmart, and so on.
ExpressJS:
Express is a small web framework that sits on top of Node JS’s web server functionality to simplify its APIs and add helpful new features. It makes it easier to organize your application’s functionality with middleware and routing. It adds helpful utilities to Node JS’s HTTP objects. It facilitates the rendering of dynamic HTTP objects.
Node JS is a platform for building i/o applications that are server-side event-driven and made using JavaScript.
Express JS is a framework based on Node JS which is used for building web applications using approaches and principles of Node JS event-driven architecture.
Feature
Express JS
Node JS
Usage
It is used to build web-apps using approaches and principles of Node JS
It is used to build server-side, input-output, event-driven apps.
Level of features
More features than Node JS.
Fewer features.
Building Block
It is built on Node JS
It is built on Google’s V8 engine.
Written in
JavaScript
C, C++, JavaScript
Framework/Platform
Framework based on Node JS
Run-time platform or environment designed for server-side execution of JavaScript.
Controllers
Controllers are provided.
Controllers are not provided.
Routing
Routing is provided.
Routing is not provided.
Middleware
Uses middleware for the arrangement of functions systematically server-side.
Doesn’t use such a provision.
Coding time
It requires less coding time.
It requires more coding time.
🏗 The MVC Concept
Express apps often follow the MVC (Model-View-Controller) pattern:
Both Node.js and NPM have their own command-line interfaces. The Node.js CLI allows developers to execute JavaScript code on the server side, while the NPM CLI is used for package management tasks such as installing and updating packages.
The NPM CLI is built on top of the Node.js CLI and provides additional functionality for managing packages and dependencies.
3. Environment Setup
Create a folder and issue the following command inside the folder
Terminal window
npminit-yes
Will create a package.json file inside the folder
{
"name": "testproject",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"