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
