Skip to content

NPM: Node.JS Package Manager

JavaScript is the most widely used language in Website and Web-Application development. There are unlimited number of resources and libraries. Whilst developing, initially the number of libraries are minimal and easy to manage, as the project progresses managing the libraries will be a tedious process. Thats where NPM comes into the picture.

Node Package Manager or simply NPM is a package manager most widely used in conjunction with Node.JS and many other Javascript. NPM is used because it gives exceptional control over the dependencies in the project.

# Install a Package

$ npm install

# Install Specific version of a package

$ npm install @version
$ npm install [email protected]

COMMAND LINE OPTIONS:

Command line is where we spend most of our time, and <strong>npm</strong> command line is very powerful and following are the few things about the npm command line options. NPM documentation is the ultimate location to get end-to-end information about the command line options. Following are the most widely used commands;

  • install:
    • This command will install a package, and any package that depends on. Following are the options available
    • 01
  • access:
    • This command will allow you to set access control on a private package, subcommands available are public, restricted, grant, revoke, ls-packages, ls-collaborators, and edit
    • 02
  • bin:
    • This command will print out the location where npm will install executables
    • 030405
  • cache:
    • This command is Used to add, list, or clean the npm cache folder.
    • 1110
  • config:
    • npm gets its config settings from the command line, environment variables, npmrcfiles, and in some cases, the package.json file.
    • 07
  • dedupe:
    • The deduplication algorithm walks the tree, moving each dependency as far up in the tree as possible, even if duplicates are not found. This will result in both a flat and deduplicated tree.
    • 08.png
  • doctor:
    • npm doctor runs a set of checks to ensure that your npm installation has what it needs to manage your JavaScript packages. npm is mostly a standalone tool, but it does have some basic requirements that must be met:
      • Node.js and git must be executable by npm.
      • The primary npm registry, registry.npmjs.com, or another service that uses the registry API, is available.
      • The directories that npm uses, node_modules (both locally and globally), exist and can be written by the current user.
      • The npm cache exists, and the package tarballs within it aren’t corrupt.
    • 09

Shashi View All

A passionate devops and automation engineer

Leave a comment