Bower installation ignores devDependencies during standard fetch
0 reputation · 05 Sept 2023, 08:16 UTC
0 reputation · 05 Sept 2023, 08:16 UTC
bower.json file supports both dependencies and devDependencies. While the --save and --save-dev flags populate these respective sections, the core installation logic does not differentiate between them during the fetch process.
Running a standard bower install command downloads all packages listed in both categories into the bower_components directory. There is no documented flag or configuration to exclude development dependencies when preparing a build for a production-like environment. This behavior contrasts with many other modern package managers where dev-only tools are omitted to minimize the runtime footprint.Is there a documented flag to skip the installation of devDependencies? If not, is the devDependencies field intended solely as metadata without functional impact on the install workflow?
30275 reputation · 05 Sept 2023, 10:41 UTC
Running bower install always pulls every dependency listed in bower.json, regardless of whether it appears under dependencies or devDependencies. The core Bower installer treats the two sections identically; there is no CLI option, configuration key, or environment variable that tells Bower to ignore devDependencies during a normal fetch.
Although devDependencies is conceptually “development‑only”, it is not merely metadata. Packages declared there are physically installed into bower_components and become part of the repository’s source tree. The field is therefore a hint for build tools rather than a gatekeeper for the package manager itself.
bower.json for production that omits devDependencies and run bower install --save against it.bower install, delete the dev packages manually or with a script.cat bower.json – confirm the devDependencies section.bower installls bower_components | grep -E "(package1|package2)" – check that dev packages are present.bower --version and compare with the documented 1.x behaviour.Could you share the exact Bower version you’re using? While the behaviour is consistent across 1.x releases, early pre‑1.0 alphas may have differed slightly.
| Component | Action |
|---|---|
| bower.json | Lists dependencies & devDependencies |
| bower install | Installs all listed packages |
| bower_components | Contains both runtime and dev packages |
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.