Node.js Basic
What is Node.js
- NodeJS is an open source, cross-platform, run-time environment and library for running JavaScript applications outside the web browser.
- It is used to create networking and server-side applications.
- It is primarily used in non-blocking, event-driven servers.
why use Node.js
Any programming language will give some reasons to choose them. Node.js is a programming technology which is able to run JavaScript code outside the web browser.
There are some advantages of using Node.js:
- it makes possible to code in JavaScript for both client and server side.
- It can speed up the development of real-time applications.
- It increases the efficiency of development process by decreasing the gap between front-end and back-end developers.
NPM
NPM(Node Package Manager) is the default package manager for Node.js. NPM allows programmers to install, update, and use open source packages.
NPM provides two major functionalities:
- NPM is an online repository for publishing open-source Node.js projects.
- NPM is a command line utility to install Node.js, version management, dependency management of Node.js packages.
NPM install package using simple syntax as follows:
npm install<package-name>
package.json file
package.json file contains all npm package files usually in the project root. It holds various metadata relevant to the project such as a project description, license information, version of the project in the particular distribution etc. and gives information to npm that allows it to identify the project as well as handle the project's dependencies.
Complete package.json of underscore as shown below:
Semantic Versioning
In every software development, semantic versioning provides the standard version as a number. Generally versioning have three digits like A.B.C .
- A is the major version
- B is the minor version
- C is the patch version
When you make a new software, you can give version using following rules:
- When you make incompatible API changes, major version is updated.
- When you add functionality on previous released software, minor version is updated.
- When you make bug fixing, patch version is updated.
Package-lock.json file
It is generated automatically when npm modifies either the node_modules tree, or package.json.
It is solely used to lock dependency to specific version number.
It provides single representation of a dependency tree which makes easier for developer.
It optimizes the NPM installs by skipping processing of previously installed packages.
No comments:
Post a Comment