QUESTION: What is npm and package.json?
Any modern JavaScript project consists not only of your own code, but also of numerous third-party libraries, frameworks, and utility tools. To manage this complex ecosystem, npm is used—the official Node.js package manager, which allows you to download, update, and remove necessary dependencies with a single command. The center of every project is the package.json file, which is a project configuration in JSON format. It contains all metadata about the application, including its name, version, author, as well as lists of required libraries for the application to run and for development.
Dependencies in this file are strictly divided into categories. The dependencies field lists libraries that are vital for the application to run in production (such as React or date-handling libraries), while devDependencies specifies tools needed exclusively at the development and build stages (such as Webpack, ESLint, or TypeScript). Additionally, the scripts section plays an important role in package.json, containing custom commands for running the project, building, testing, or linting code, allowing you to execute complex command chains with a simple shortcut like npm run build. To ensure stability and reproducibility of the build on any computer or server, a package-lock.json file is created, which locks the exact versions of all installed packages and their sub-dependencies, guaranteeing that you and your coworker will run an absolutely identical set of code on your devices.