npm, short for Node Package Manager, is the package manager that ships with Node.js. It installs, updates and publishes JavaScript packages. npm scripts are named commands in the scripts field of package.json, which you run with npm run <script-name>.
{
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js",
"test": "jest",
"build": "webpack --mode production",
"lint": "eslint .",
"prestart": "npm run build"
}
}
Scripts give a project one shared set of commands for development, testing and production builds. npm puts the project's installed tools on the PATH, so nodemon or jest run without a global install. A pre or post script runs before or after the script with the matching name, so prestart builds before start. Scripts run in the system shell, sh or cmd.exe, so a Unix-only command fails on Windows.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓