Node.js › Node.js Fundamentals & Runtime Architecture
What is npm, and what is its relationship to the Node.js runtime itself?
BeginnerAnswer
npm (Node Package Manager) is the default package manager bundled with Node.js installations, providing a command-line tool for installing, publishing, and managing third-party JavaScript packages, along with npmjs.com, the world's largest public package registry hosting those packages -- while npm ships alongside Node.js by default, it's technically a separate project with its own independent versioning and release cycle, and alternative package managers (Yarn, pnpm) can be used in its place for the same fundamental purpose of managing a project's dependencies.
npm init -y # creates a new package.json
npm install express # installs a package and adds it as a dependency
npm install --save-dev jest # installs as a dev-only dependency
npm run test # runs a script defined in package.jsonReal-world example A new Node.js project starts with 'npm init' to create a package.json file, then uses 'npm install' to add Express as a runtime dependency and Jest as a development-only dependency, establishing the project's exact dependency tree, which npm records precisely in a package-lock.json file for reproducible installs.