Spunk Autos

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

ApproachHow it worksGainsCosts
VendoringCopy library source into your repoWorks offline; you see every lineUpdates are manual; repo grows
Pinned CDN script tagLoad a fixed version from a public CDNNo build stepDepends on a third party; use subresource integrity
OS packagesInstall libraries with the system package managerSecurity updates come with the OSVersions may be old; tied to one server
Container imageBake dependencies into an imageSame environment everywhereImages to build, store and patch
No dependencyWrite the small feature yourselfNothing to updateYour 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

  1. How many dependencies, including indirect ones, does the project need?
  2. Who will apply security updates, and how will they hear about them?
  3. Must the build work without internet access?
  4. Will someone else need to rebuild this in two years?