Package Managers
This content is for Backend. Switch to the latest version for up-to-date documentation.
A Package Manager is a tool that automates the process of installing, upgrading, configuring, and removing software packages (libraries) in your project.
npm (Node Package Manager)
Section titled “npm (Node Package Manager)”Focus Topic
npm is the default package manager for Node.js. It is the world’s largest software registry.
When you install Node.js, you get npm automatically.
Key Commands
Section titled “Key Commands”npm init: Sets up a new project (createspackage.json).npm install <package-name>: Downloads a library and adds it to your project.npm start: Runs the start script defined in your package file.
structure
Section titled “structure”- package.json: The manifest file. It lists your project’s name, version, and dependencies.
- node_modules: The folder where the actual code of the downloaded packages lives. Do not edit files here!
- package-lock.json: Ensures everyone on your team installs the exact same versions of packages.
Other Package Managers
Section titled “Other Package Managers”- yarn: Created by Facebook to be faster and more secure than npm (though npm has caught up).
- pnpm: “Performant npm”. It saves disk space by using a shared store for packages, so you don’t have duplicates on your computer.