Separate runtime and development dependencies
Quick answer
Runtime dependencies provide code required when a package runs; development dependencies support building, testing or authoring. npm resolves both according to the manifest and lockfile.
Tooling examples
Example 1. Context: projects/npm-lab. Run in a fresh prepared fixture copy; see its README. Local check available; consult validation evidence for what was asserted.
npm pkg get dependenciesExpected observation: The manifest includes @lesson/units.
Example 2. Context: projects/npm-lab. Run in a fresh prepared fixture copy; see its README. Local check available; consult validation evidence for what was asserted.
npm ci --offline --ignore-scripts --no-audit --no-fund --omit=devExpected observation: Successful install; the development-only marker is absent.
How the tooling works
The lab declares a local units package under dependencies and a local marker tool under devDependencies. A build environment often needs both groups, even if the deployed artifact only needs runtime code. npm ci --omit=dev omits development-only packages on disk but can still resolve them in the lockfile. Transitive dependencies are dependencies of dependencies. A library peer dependency states a compatibility relationship with a host, not a general replacement for dependencies. Do not assume a dependency is optional simply because another package also installs it.
Common mistakes
Build before pruning development tooling. Do not move required runtime modules into devDependencies to shrink installs.
Practice
Use a fresh lab copy, run a normal install and an omit-dev install, then compare whether the marker package is present.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Separate runtime and development dependencies — Knowledge Check
Assess tooling contracts, diagnostic reasoning and transfer to a project.
Where does a package used by application code at runtime normally belong?
When should build tools be available if the production artifact must be generated?
What is a transitive dependency?
In Separate runtime and development dependencies, what is the expected observation for example 1 in its documented setup? npm pkg get dependencies
In Separate runtime and development dependencies, what is the expected observation for example 2 in its documented setup? npm ci --offline --ignore-scripts --no-audit --no-fund --omit=dev