Introduction to NPM - Node Package Manager


The npm (Node package manager) is a repository of open-source software packages hosted by npm for the Node. js developer community.

It helps you to download, install and manage all the third-party packages/dependencies you need to import in your project.

Npm installs packages locally or globally for your project. It puts your project modules in place so that node can find them and also manage the package conflicts.



Download NPM (Node Package Manager)

You do not need to download Npm separately as it comes with the node you have already downloaded and installed. 

If you haven't downloaded node yet, Please read the Node Environment Setup where you can learn step by step guide to download and install Node for your operating system.


Check npm version installed in your system





package.json


  • The package.json is the configuration file npm (node package manager) uses to manage all the dependencies and metadata in the project.
  • it contains the lists of the packages your project depends on.
  • It specifies the versions of the packages your project can use.



Create package.json file

you can create package.json using the npm init command in the visual studio terminal or the command prompt and press enter.

npm init command will take you through some questionnaire, For now just skip all those questionnaires by pressing Enter for every question. It will take the default for each question. 





  1. On the command line, navigate to the root directory of your package.
      cd /path/to/package
    
  2. Run the following command:
      npm init
    
  3. Answer the questions in the command line questionnaire.