Guide
Add a Front‑End Dependency with Bower Using the --save Flag
Learn how to add a front‑end package with Bower’s --save flag, verify the installation, and roll back changes if needed.
Published by Tasadduq Burney
15 Aug 2026, 18:19 UTC
2 min32.9K views0

Add a Front‑End Dependency with Bower Using the --save Flag
Desired outcome: record a specific version of a front‑end library in bower.json and place its files in bower_components so the project can be reproduced.
Prerequisites
- Node.js and npm installed.
- Access to run global npm commands (may require sudo or equivalent permissions).
- A project directory with a
package.json(optional) where you want to manage front‑end deps.
Procedure
- Install Bower globally if not present:
npm install -g bower - Verify the installation:
bower -v - Navigate to the project root and ensure a
bower.jsonexists. If missing, create it:
(accept the defaults or edit as needed.)bower init - Add the desired package, for example jQuery, and save it to the manifest:
bower install jquery --save - Confirm the installation:
bower list - Inspect the generated manifest:
cat bower.json
Expected Checks
- The output of
bower listshows the package with a version, e.g.jquery#3.6.0. bower.jsoncontains adependenciessection with an entry like"jquery": "3.6.0".- The folder
bower_components/jqueryexists and contains the library files. - Your application can reference the file, e.g.
<script src="bower_components/jquery/dist/jquery.min.js"></script>.
Recovery Options (Rollback)
Because the operation modifies bower.json and adds files under bower_components, you can revert:
- Remove the dependency line from
bower.json(or delete the wholedependenciesentry). - Delete the installed folder:
rm -rf bower_components/ - Commit the cleaned
bower.json(and optionally the removed folder if it is not ignored).
Limitations and Practical Verification
- Bower is deprecated; new projects should consider alternatives like npm or Yarn.
- The
--saveflag updates onlybower.json; there is no automatic lockfile, so exact versions must be specified manually for deterministic builds. - Global installation can cause version conflicts across projects; consider using a local copy via
npx boweror an npm script. - To verify that the dependency works, run your project's build or test suite after installation, e.g.
npm testif you have a front‑end test.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.