npm: Packages & Scripts in JavaScript
npm (bundled with Node) manages dependencies and task running: npm init scaffolds package.json (name, version, scripts, dependencies), npm install <pkg> adds exact-versioned entries plus a lockfile for reproducible installs, and npm run <script> executes defined commands (dev, build, test). node_modules holds the hoisted dependency tree — never committed, rebuilt from the lockfile.
Scripts replace task runners for most projects (vite, jest, eslint invocations), npx runs binaries without installing, and semantic versioning ranges (^1.2.3) balance freshness with stability. Alternatives (yarn, pnpm) share the manifest concepts with different stores.
init scaffolds
npm init -y writes package.json — identity, scripts, and dependency lists in one manifest.
install pins exactly
npm install lodash records ^4.17.21 plus lockfile exactness — teammates and CI install identically.
scripts run tasks
"scripts": {"dev": "vite", "test": "node --test"} — npm run dev/build/test standardizes workflows.
npx executes once
npx create-app runs packages without installing — scaffolders and one-off tools without footprint.
$ npm init -y$ npm install lodash$ npm run testRecommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in JavaScript yourself — building beats watching.