Npm script
An npm script is a named command declared in a project's package.json file and runnable through npm.
Web Components in Action
npm scripts are named commands declared in package.json and executed through npm to automate project tasks.
- How it is used
- Automates project tasks and shortens repeatable build commands through package.json.
- How deep it goes
- Defines scripts, demonstrates npm run execution, and chains component builds, but stops short of general orchestration theory.
- Examples
- Uses echo, local Rollup commands, component-specific build scripts, and an aggregate script joined with &&.
- What you can do after
- Operate/configure named npm commands for individual component bundles and complete multi-component builds.
Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform
An npm script is a named command configuration in a project's package.json file that can be invoked through npm.
- How it is used
- Standardizes microservice startup and test commands while hiding project-specific command details.
- How deep it goes
- Defines scripts in package.json and demonstrates invocation and live-reload configurations without examining npm internals.
- Examples
- Illustrates microservice startup with nodemon and Jest test execution with watch mode.
- What you can do after
- Apply it via npm to configure and run named startup and test commands.
Pro Angular 16
The scripts section is the package.json field containing named command definitions that a package manager can execute.
- How it is used
- Runs project-local development, build, watch, testing, and supporting commands through package.json.
- How deep it goes
- Defines command mappings and execution syntax, but does not detail npm’s script resolution internals.
- Examples
- Uses start, build, watch, test, and json scripts, including a json-server command serving restData.js on port 3500.
- What you can do after
- Operate/configure project tools through named npm commands executed from the package.json directory.
Essential TypeScript 5, Third Edition
The scripts section is the package.json configuration section that defines named commands runnable through npm.
- How it is used
- Centralizes repeatable compiler, server, bundler, build, test, and lint commands behind short npm invocations.
- How deep it goes
- Defines scripts through complete package.json examples and shows parallel execution, but does not detail npm script resolution internals.
- Examples
- Demonstrates tsc-watch, node dist/index.js, json-server, webpack serve, Angular CLI, and React scripts in package.json.
- What you can do after
- Operate development workflows with npm start and configure scripts that launch tools separately or in parallel.
Read how Essential TypeScript 5, Third Edition explains npm script →
Also covered in
- Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond
- React in Depth
- Build a Frontend Web Framework (From Scratch)
- Secrets of the JavaScript Ninja, Third EditionIn early access (MEAP)
What to know first
- package.jsonpackage.json is the standard JSON manifest for an npm or Node.js package, declaring metadata, dependencies, scripts, entry points, and related configuration.
- HTTP requestAn HTTP request is a message sent by a client to a server using the Hypertext Transfer Protocol, specifying a method and target and optionally including headers and a body.
- decoratorA decorator is a programming-language construct that adds metadata or behavior to, or transforms, a program declaration, often a function or class.
- packageA software package is a named unit that groups related software components, either for organization and compilation or for distribution and reuse.
Related concepts
- package.jsonpart of · package.json is the standard JSON manifest for an npm or Node.js package, declaring metadata, dependencies, scripts, entry points, and related configuration.
- npm start commandincludes · npm start is an npm command that runs the package manifest’s configured start script.
- deployment pipelineuses · A deployment pipeline is a repeatable sequence of stages that builds, tests or validates, packages, and delivers software changes toward release or deployment.
- toolchainconfigures · A toolchain is a coordinated collection of software tools that work together to develop, build, analyze, test, or deliver software.
- web serviceconfigures · A web service is a network-accessible software service that exposes functionality or data through a defined interface using web protocols.
Questions about npm script
What is npm script?
An npm script is a named command declared in a project's package.json file and runnable through npm.
Which Manning books explain npm script?
Web Components in Action, Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform, Pro Angular 16 and Essential TypeScript 5, Third Edition.
What should I know before learning npm script?
Manning books that teach npm script usually introduce package.json, HTTP request, decorator and package first.
What kinds of npm script are there?
Kinds of npm script include npm start command.
What is npm script part of?
Npm script is part of package.json. package.json is the standard JSON manifest for an npm or Node.js package, declaring metadata, dependencies, scripts, entry points, and related configuration.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



