A Beginner’s Guide to NPM

Aradhya Singh
2 min readNov 28, 2022

--

NPM or “node package manager” is the world’s largest software registry. There are more than 800,000 code packages in the registry. It’s a publishing and sharing tool used by open-source developers worldwide. Developers install code in their project using package managers rather than copying and pasting it.

NPM consists of three Components:-

1 . Website : You can find packages for your project, set up profiles to manage and access private and public packages, and more on the official npm website.

2 .Command-line tool (CLI)- for downloading and publishing packages.

3 . Registry : The registry is a significant and widely accessible database of JavaScript projects and meta-data. You are free to use any supported npm registry, including your own. As long as you abide by the terms of use, you can even utilise someone else’s registration.

How to install NPM-

npm is installed with Node.js. This implies that in order for npm to be installed on your machine, Node.js must first be installed.

Visit the Node.js website : https://nodejs.org to get the programme.

Package.json files, which are used to define all npm packages. Typically, the root directory of each npm project contains a file named package.json. Important data is contained in the package.json, a plain text file that npm utilises to identify the project and manage dependencies.

JSON must be used to format the package.json file’s content.

Important npm Commands-

  • npm : You use the npm command from a terminal to locate the npm CLI on your computer.
  • npm -v : this command will show your system’s current version of npm.
  • npm init : A package.json file is created in our directory. Basically, it asks several questions before producing a package.json file in the project directory where it is now running.
  • npm start : executes a command that has been specified in the scripts’ start attribute. If not defined, the node server.js command will be executed.
  • npm build : Used to build a package
  • npm install <package_name> : The npm install command is used to install a new package.
  • npm uninstall : remove a package out of the package. json file and remove the module out of the local node modules folder.
  • npm update : The selected package is updated by this command. If no package is specified, all the packages in the given location are updated.
  • npm update -g : The update action will be applied to all globally installed packages by this command.
  • npm ls : lists every installed package along with all of its dependencies.

--

--