Node.js
What is Node.js?
An open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.
Name four basic components of Node.js
Event Emitters: They are objects in Node.js that trigger events by sending a message to signal that an action was completed. We can also write our own code that listens to events from an event emitter. For example, if you have done some frontend work, then you probably know how much interaction we need to handle in our applications, such as mouse clicks, keyboard button presses, and other mouse movements. Similarly, on the backend environment in Node.js, we can build a similar system using the events module, which offers EventEmitter class which we use to handle our events. Callbacks: These are functions called when a task is completed, which prevents any kind of blocking while allowing the rest of the code to run in the meantime. As we have to work with a lot of asynchronous tasks in Node.js, we need them everywhere for making seamless and faster applications. Buffers: A class called Buffer in Node.js is designed to handle raw binary data. They correspond to some raw memory allocated outside V8. Buffers are an array of integers that can't be resized having a whole bunch of methods specifically for binary data. For example, the integers in buffer represent a byte with limited values from 0 to 255 inclusive, if you console.log() to print a Buffer instance, a chain of values in hexadecimal will be received. Module System: As a part of the Node.js ecosystem you will be using the Module for implementing complex functionality by just using the Modules provided by Node.js, these are JavaScript files that contain all the organized and complex features that anyone can reuse through the Node.js application.
What are some prominent Node.js frameworks?
Express.js: Provides a very minimal interface and tools that are required to build our application, quite flexible to use, and comes with numerous modules available on npm which can be plugged directly into Express. Meteor.js: A great go-to framework for making JavaScript applications, comes with built-in MongoDB handlers with support for GraphQL. When you run the "meteor create myapp" and run it, an HTML/JavaScript web page is provided with a MongoDB backend. You can use Meteor.js as an effective alternative in your list of frameworks that helps you cut the development time with ease of maintenance. Otherwise, I will recommend sticking with Express if you are building a simple web app. Sails.js: An MVC framework allows you to quickly build REST APIs, single-page apps, and real-time apps. If you are looking to master some serious skills then Sails.js is highly recommended as you get many benefits with it, such as real-time support with WebSockets and it uses the "convention over configuration" approach. Koa.js: If you are looking to build robust applications that are future proof and easy to maintain then Koa.js is a good choice. A Koa application is an object containing an array of some middleware functions that are later executed in a manner of stacks. Nest.js: Inspired by Angular and built with TypeScript, uses Express.js under the hood which makes it compatible with most of Express middleware. You can build an efficient and scalable application with Nest.js as it provides a great modular structure for organizing code into separate modules.
What JavaScript should you know for Node.js?
If you are a frontend developer looking to master some backend skills then you don't have to spend a huge amount of time learning JavaScript before getting started with building Node.js applications. But in case if you are a complete beginner who's looking to master Node.js in the minimum possible time then you must learn the following concepts before you deep dive into the Node.js environment. Arrow Functions Types Expressions Functions Lexical Structures this Loops and Scope Arrays Template Literals Strict Mode ES6/ES7 In Node.js you will be handling a lot of asynchronous programming and for that, the following concepts are recommended to learn. Timers Promises Closures The Event Loop Async programming and callbacks
What is NPM used for?
Managing multiple versions of code and code dependencies, running packages without downloading them (using npx), and many more.
What is NPM?
Node Package Manager is the world's largest Software Registry with over 800,000 code packages. Using NPM the right way can help a lot as managing packages becomes pretty handy with NPM while we develop applications that require a number of dependencies.
What is the built-in require function used for in Node.js?
Node.js follows the CommonJS module system, and the builtin require function is the easiest way to include modules that exist in separate files. The basic functionality of require is that it reads a JavaScript file, executes the file, and then proceeds to return the exports object. An example module: console
Why node.js is useful and how to approach it
Node.js has been one of the biggest game-changer since its release, bigger companies like Uber, Medium, PayPal & Walmart switched their tech stack to Node.js. You can make really powerful applications with Node.js such as real-time tracking apps, video and text chat engines, social media apps, etc. And learning Node.js is becoming one of the hottest skills for developers, the roadmap that I have prepared is based on how I learned it with my own experience and tips. Before deep-diving into this Node.js roadmap make sure that you have a clear & concise goal of what you want to build with Node.js otherwise you will give up in between the learning path just like I did. Keeping a goal will help you focus on learning the essential skills on the top, instead of figuring out whether you need to learn them or not.
What is PM2?
PM2 is a production process manager for Node. js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks.
What is NPX useful for?
Running packages without downloading them
What are some prominent RDBSes used with Node.js?
SQL Server: A relational database management system developed by Microsoft, it supports ANSI SQL (a standard SQL language). However, SQL comes with its own implementations. MySQL: Another great database management system that allows you to mage relational databases. Open-source backend software developed by Oracle, also with MySQL we get the flexibility of choices as we can change the source code according to the needs. MySQL is a pretty easy alternative as compared to Oracle Database & Microsoft SQL server. PostgreSQL: Developed by a worldwide team of developers as it is open source. It runs on all major operating systems including Linux, UNIX & Windows. PostgreSQL supports a large part of the SQL standard while offering some great features such as Complex SQL queries, Foreign Keys, Trigger, Transactions, Multiversion concurrency control (MVCC), Streaming Replications etc. MariaDB: An improved version of MySQL that comes which various inbuilt powerful features, security, and performance improvements that you will not find in MySQL. There are several reasons why you should opt for MariaDB instead of MySQL for large-scale applications. For example, MariaDB has a larger connection pool supporting up to 200,000+ connections whereas MySQL has a smaller connection pool. In short, MariaDB is faster than MySQL.
What three components does NPM consist of?
The Command Line Interface (CLI): It runs in the machine's terminal environment and how most of the developer interact with NPM The Registry: A large public database of JavaScript software and the meta-information. The Website: You can discover new packages, and manage other aspects of your npm experience.
What is the n package?
n downloads a prebuilt Node. js package and installs to a single prefix (e.g. /usr/local ). This overwrites the previous version. The bin folder in this location should be in your PATH (e.g. /usr/local/bin ).