Node.js is a back-end web development framework written in the programming language JavaScript.
It allows to create server-side web applications in JavaScript.
Take into account that JavaScript was a programming language intended initially for the client side, so JavaScript back-end frameworks allows to add server side functionality without having to learn a different programming language.
To work with Node.js, you need to be familiar with JavaScript. You can read an introduction to JavaScript on this post.
Node.js is a runtime built on V8, the JavaScript Chrome engine.
Electron is a desktop application framework based on Node.js. You can read an introduction to Electron on this post.
Components of Node.js
A Node.js project has at least the following components:
- package.json file: it contains the project metadata.
- scripts: they are JavaScript files
Installing Node.js
On Linux systems, you can install Node.js opening the terminal and typing:
sudo apt install nodejs
Learning Node.js
You can find the official starting guide for Node.js on this external link.
Node.js examples
You can find the official JavaScript examples on this external link.
Node.js Documentation
You can find official Node.js documentation on this external link.
Node.js Tools
npm is a tool for Node.js. It helps to install libraries for projects.
npm can be install on Linux systems opening the terminal and typing:
sudo apt install npm
Create a new folder and put your js program inside.
Then go to this folder and type:
npm init
Complete the steps to create a package.json file.
You can use npm to install a library inside a folder, going to that folder and entering a command like this:
npm install library_name --save
Node.js Packages
npm allows to install packages or libraries. This is a list of popular Node.js packages.
Express.js
Express.js has the package name “express”.
It is the de facto server framework for Node.js.
cors
Package for providing a Connect/Express middleware.
EJS
EJS has the package name “ejs”.
EJS files uses the extension .ejs.
mongoose
mongoose package adds MongoDB support.
pg / pg-pool
pg / pg-pool adds PostgreSQL support.
bodyparser
Body parsing middleware.