liveBook · Manning

Production dependency

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

A production dependency is a software package required when running an application in production but not for development.

A production dependency is a package required to run an application in production, rather than only during development or testing. Install only production dependencies with npm install --omit=dev; the resulting environment is smaller and matches the runtime requirement. section 2.6.7 section 9.7.3

Use production dependencies when:

  • The running microservice imports or otherwise needs the package outside test code. section 9.7.3
  • A production container should omit development dependencies while retaining the packages needed by the deployed service. section 5.5.3
  • A package supports testing but is also used by the production microservice; install it as a regular dependency rather than with --save-dev. section 9.7.3

Install dependencies for a production container

A production Dockerfile copies package manifests, runs npm ci --omit=dev, copies the application source, and starts the service with npm start. A development Dockerfile installs all dependencies and uses npm run start:dev instead. section 5.5.3

npm install --omit=dev

Open the production-only installation command used to prepare a runtime environment without development dependencies. section 2.6.7

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

How deep it goes
Explains classification and installation, then applies them in Dockerfiles; it stops short of dependency-resolution internals.
Examples
Uses npm install --omit=dev, npm ci --omit=dev, production Dockerfiles, and MongoDB used by both tests and the service.
What it assumes
Assumes familiarity with Node.js projects, package.json, npm, and Dockerfile commands; distinguishes development and production installation practices.
What you can do after
Operate Node.js deployments with npm and Docker while installing only packages required by the production microservice.
How it connects
Connects production dependencies with development dependencies, npm, Dockerfiles, microservices, MongoDB, and automated testing.

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.