Websites and web tools
Package manager alternatives: other ways to handle dependencies
A language package manager is the usual way to add libraries to a project, but it is not the only way. This page compares the alternatives, explains what each gives up, and helps the owner of a small site, such as a detailer's gallery or a shop's booking page, decide what fits.
What a package manager does for you
- Downloads libraries and the libraries they depend on.
- Records exact versions in a lockfile so every install matches.
- Updates and removes libraries on request.
- Runs project scripts such as build and test.
Any alternative must cover these jobs another way, or you must accept going without them.
The alternatives compared
| Approach | How it works | Gains | Costs |
|---|---|---|---|
| Vendoring | Copy library source into your repo | Works offline; you see every line | Updates are manual; repo grows |
| Pinned CDN script tag | Load a fixed version from a public CDN | No build step | Depends on a third party; use subresource integrity |
| OS packages | Install libraries with the system package manager | Security updates come with the OS | Versions may be old; tied to one server |
| Container image | Bake dependencies into an image | Same environment everywhere | Images to build, store and patch |
| No dependency | Write the small feature yourself | Nothing to update | Your time; risk of bugs in hard areas |
Choosing by situation
A static site with one small script
A pinned script tag, with an integrity hash and crossorigin attribute, or a vendored copy is simpler than a whole toolchain. Many small features, such as a mobile menu toggle, need no library at all.
An app with many libraries
Use a package manager with a committed lockfile. The alternatives become hard to manage once dependencies have their own dependencies.
A server you must keep stable for years
Containers or OS packages can make sense, as long as someone owns patching. Pin base images and rebuild on a schedule.
Alternative package managers
Within a language there are often several package managers that read the same registry. They differ in install speed, how they store files on disk, and lockfile format. Switching rarely changes your app; it changes the developer workflow. Do not mix two on the same project, because their lockfiles will disagree.
Questions before you choose
- How many dependencies, including indirect ones, does the project need?
- Who will apply security updates, and how will they hear about them?
- Must the build work without internet access?
- Will someone else need to rebuild this in two years?