liveBook · Manning

Npm start command

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

npm start is the conventional npm command for launching a Node.js application through its configured start script.

npm start is the conventional command for launching a Node.js application through the start script configured in package.json. The script can hide the entry file, command-line arguments, and other startup details behind one project-independent command. section 2.6.7

Use the command as part of a predictable project startup workflow:

  • Install dependencies with npm install; use npm install --omit=dev when preparing an environment that needs only production dependencies. section 2.6.7 section 10.5.1
  • Run npm start from the project directory to invoke the command recorded under scripts.start in package.json. section 2.6.7 section 10.5.1
  • Set required environment variables before retrying a service that reports missing configuration. section 10.5.1

A package-defined start command

A project can define "start": "node src/index.js" in package.json. After changing into the project directory and installing dependencies, run npm start without needing to remember the entry-file name. section 2.6.7

cd chapter-2/example-3
npm install 
npm start

Follow the compact project-directory workflow: change directory, install dependencies, and start the application. section 2.6.7

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Explains the package.json script indirection and operational prerequisites, but does not examine npm script internals.
Examples
Uses node src/index.js, package.json, npm install, npm install --omit=dev, and standalone microservice startup.
What it assumes
Assumes Node.js and npm are available, while teaching dependency installation and required environment configuration.
What you can do after
Operate/configure Node.js applications and microservices through a consistent start command.
How it connects
Connects npm scripts, package.json, Node.js, production dependencies, environment variables, and development mode.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.