


Another tool that helps us manage our dependencies is the package-lock.json file. Here we can see the version of the json package and see the Semantic Versioning that has been applied to denote the version of the package.

Before you work with NPM packages, it is highly recommended that you have Node.js installed on your system so that we can work with it easily. In this article, we will be seeing how we can work with NPM and manage our Javascript Project with much efficiency and dive deep into some advanced features of NPM as well. The purpose of NPM further enforces the belief that using Third-Party Packages can sometimes be used to further optimize the applications rather than reinventing the wheel with each iteration.

If you have worked with any Node.js Project or with any other Javascript Framework, you might have encountered NPM. These packages are available online and hence can be downloaded by easy installation and managed in the project with dependency management. The concept of NPM is quite similar to Ruby Gems or Python Pip Packages, which revolves around the purpose of modularity. While talking about Node.js, it is incredibly important to understand about NPM or Node Package Manager, which is the primary intent of our article. This makes Node.js incredibly fast and reliable for real-time processing and operations. In Node.js, everything is single-threaded and all users are sharing the same thread. This means that events are handled continuously which are taken care of in the order they are raised. In Node.js on the other hand, events are handled asynchronously. After the primary order has been served, the Waiter can serve you a glass of water and so forth. This means, that before your order if you need a glass of water, that will not be served before your primary order has been served. In an Apache Web Server, the Waiter will first take your order and will not do anything else before your order has been served. Let's take the example of a Restaurant and a Waiter. This means that in Apache, a single thread waits for the file system to finish its operation before it can do anything else. In Apache, all requests are single-threaded and follow a monolithic structure. Example: express, body-parser etc.To explain this further, let me take the example of Apache Web Server that is traditionally used to deploy PHP-based Web Applications. It will be installed if a third person tries to clone your package.
NPM SAVE DEV WITHOUT INSTALL INSTALL
It will be installed if a third person tries to install or clone your package. All development dependency is listed under devDependencies in package.json. All core dependency is listed under dependencies in package.json. The package installed is not a core rather development dependency. Example: nodemon –save –save-dev The package installed is core dependency. When someone installs your package they will not install any development dependencies but if they clone the repository, then they will install all the development dependencies too. In package.json file under the devDependencies section contains the list of all development dependencies. A development dependency is any package that absence will not affect the work of the application. Npm install –save-dev: When –save-dev is used with npm install, it signifies that the package is a development dependency. When someone installs your package they will also install all the packages listed in the dependencies section of package.json. The npm install will also lead to a similar result. In package.json file under the dependencies section contains the list of core dependencies. A core dependency is any package without which the application cannot perform its intended work. Npm install –save: When –save is used without -dev, it signifies that the package is core dependency.
NPM SAVE DEV WITHOUT INSTALL DOWNLOAD
Both commands will lead to download and installation of packages from NPM servers but they have a bit different ways. It has two very frequently used commands to downloaded different dependencies, npm install -save and npm install -save-dev. NPM (Node Project Manager) is a package manager used by JavaScript runtime environment Node.js.
