1.

What is npm?

Answer»

Npm or Node Package Manager is the default package manager for Node.js.It works as:

  1. An online repository called as npm registry USED for the open-source Node.js projects.npm registry is a large DATABASE with around half a million packages. DEVELOPERS can download from and publish packages to the npm registry.
  2. Npm is also a  command-line utility for interacting with an online repository that helps in package installation, version management, and dependency management.

Few of the IMPORTANT  npm commands are:

  • Any package can be installed  by running a simple command

“ npm install <name of the package> “.

This will install the module under the path, “./node_modules/”. Once installed the module could be used just like they were built-ins. Dependency management could also be done with npm. Our node project will have a package.json which will have all the dependencies needed for our project. If we perform “npm install” from project root all the dependencies listed in the package.json file will be installed.

  • “npm init” Here package.json file is created that is where all dependencies are included.
  • “npm update <package_name>”  where the specific package is updated with new features
  • “npm uninstall <package_name>” where the specific package is uninstalled. It’s then removed from the “node_modules” folder.
  • “npm list” is used to list all the packages installed.
  • npm help” is the built-in help command.To get help for a particular command, use

“npm <command> -H



Discussion

No Comment Found