πŸ“¦ PACKAGE MANAGER HIERARCHY β€” Dari npm sampai Bun, pip sampai uv

Package manager bukan hanya β€œtool untuk install library.” Di baliknya ada: dependency resolution algorithm, lockfile format, content-addressable storage, virtual environment isolation, dan security supply chain. Memahami ini = memahami kenapa Bun 25x lebih cepat dari npm dan uv 100x lebih cepat dari pip.

Konteks

Ini langsung relevan untuk proyek Laravel (PHP/Composer), Next.js (Node/npm atau Bun), dan Python scripting yang sudah ada di vault. Pilihan package manager mempengaruhi CI/CD speed, disk usage, dan reproducibility.


Daftar Isi


Mengapa Package Manager Adalah Masalah Sulit

Dependency Resolution β€” NP-Hard Problem

Bayangkan kamu install:
  Package A v1.0 β†’ butuh Package C >= 2.0
  Package B v1.0 β†’ butuh Package C >= 2.5 dan < 3.0
  Package D v1.0 β†’ butuh Package C ~= 2.8 (compatible release)

Package manager harus find:
β†’ Versi C yang satisfy SEMUA constraint sekaligus
β†’ Jika tidak ada: error, atau compromise

Ini secara matematis adalah Boolean Satisfiability Problem (SAT)
β†’ NP-complete untuk kasus umum
β†’ Itulah kenapa dependency resolution bisa lambat dan tidak deterministik

Algoritma yang berbeda dipakai:
npm v1-2: greedy, bisa duplikat package (node_modules hell)
npm v3+:  flat tree, deduplicate
yarn:     SAT solver, reproducible via lockfile
pnpm:     content-addressable store + symlink, paling efisien
uv:       PubGrub algorithm (Rust), fastest currently known

Dependency Hell β€” Masalah Nyata

NODE_MODULES HELL (sebelum pnpm):

project/
└── node_modules/
    β”œβ”€β”€ package-a/
    β”‚   └── node_modules/
    β”‚       └── lodash@4.0.0     ← copy 1
    β”œβ”€β”€ package-b/
    β”‚   └── node_modules/
    β”‚       └── lodash@4.0.0     ← copy 2 (identik!)
    └── package-c/
        └── node_modules/
            └── lodash@4.0.0     ← copy 3 (identik!)

Hasil: node_modules bisa 500MB untuk project sederhana
"heaviest object in the universe" = node_modules folder

DIAMOND DEPENDENCY (klasik):
        Your App
        /      \
    Pkg A      Pkg B
       \       /
     lodash@4  lodash@3
         ↑
     CONFLICT!

Node.js Ecosystem β€” Evolusi dari npm sampai Bun

Timeline & Apa yang Diperbaiki Setiap Iterasi

2010: npm (Node Package Manager)
β”œβ”€β”€ Original, bundled dengan Node.js
β”œβ”€β”€ Sequential install (satu per satu)
β”œβ”€β”€ Non-deterministic: install dua kali = hasil berbeda
└── Masalah: lambat, tidak reproducible

2016: yarn (Facebook)
β”œβ”€β”€ Parallel install: 2-3x lebih cepat dari npm
β”œβ”€β”€ Lockfile (yarn.lock): reproducible install
β”œβ”€β”€ Offline cache: tidak download ulang jika sudah ada
└── Masalah: masih node_modules, duplikasi masih ada

2017: npm v5 (respon ke yarn)
β”œβ”€β”€ package-lock.json: lockfile seperti yarn
β”œβ”€β”€ Lebih cepat tapi masih kalah dari yarn
└── Masalah: node_modules masih besar

2017: pnpm
β”œβ”€β”€ Content-addressable store: satu file = satu copy di disk
β”œβ”€β”€ Symlink ke global store (bukan copy)
β”œβ”€β”€ 2-3x lebih cepat dari npm, lebih hemat disk
└── node_modules masih ada tapi jauh lebih kecil

2020: yarn berry (v2+) dengan PnP
β”œβ”€β”€ Zero-installs: tidak perlu install sama sekali
β”œβ”€β”€ Plug'n'Play: tidak ada node_modules!
β”œβ”€β”€ Import dari .yarn/cache zip files langsung
└── Masalah: compatibility issue dengan beberapa package

2022: Bun
β”œβ”€β”€ Runtime baru (bukan Node.js), package manager, bundler, test runner
β”œβ”€β”€ Install 25x lebih cepat dari npm
└── Bukan hanya package manager β€” ini RUNTIME baru

npm β€” Fondasi yang Harus Dipahami

# npm fundamental yang sering salah kaprah
 
# INSTALL
npm install              # Install dari package.json
npm install pkg          # Install + tambah ke dependencies
npm install -D pkg       # devDependencies (tidak di-bundle ke production)
npm install -g pkg       # Global install (hindari jika bisa)
npm ci                   # ← WAJIB di CI/CD! Install PERSIS dari lockfile
 
# npm ci vs npm install β€” PENTING:
# npm install: bisa update patch version, bisa ubah lockfile
# npm ci:      HANYA dari lockfile, gagal jika lockfile tidak sinkron
#              Lebih cepat, lebih reproducible, hapus node_modules dulu
 
# WORKSPACE (monorepo)
# package.json root:
{
  "workspaces": ["packages/*", "apps/*"]
}
npm install -w packages/ui    # Install di workspace spesifik
npm run build --workspaces    # Run di semua workspace
 
# SECURITY
npm audit                     # Cek vulnerability di dependencies
npm audit fix                 # Auto-fix yang bisa di-fix
npm audit fix --force         # Force major update (hati-hati breaking change)
npm outdated                  # Lihat package yang bisa di-update
 
# SCRIPTS
{
  "scripts": {
    "start": "node index.js",
    "dev": "nodemon index.js",
    "build": "tsc",
    "test": "jest",
    "prepare": "husky install",  # ← auto-run setelah npm install
    "prepublishOnly": "npm test" # ← auto-run sebelum npm publish
  }
}

pnpm β€” Yang Seharusnya Kamu Pakai

# CARA KERJA pnpm:
# ~/.pnpm-store/ (global content-addressable store)
# └── v3/
#     └── files/
#         β”œβ”€β”€ 00/abc123...  ← setiap file disimpan sekali
#         β”œβ”€β”€ 01/def456...
#         └── ...
#
# project/node_modules/ (symlink ke store)
# └── .pnpm/
#     └── lodash@4.17.21/
#         └── node_modules/
#             └── lodash β†’ ~/.pnpm-store/.../lodash  ← SYMLINK, bukan copy
 
# Install pnpm
npm install -g pnpm
# atau: corepack enable && corepack prepare pnpm@latest --activate
 
# SETUP PROJECT
pnpm init
pnpm add express         # dependencies
pnpm add -D typescript   # devDependencies
pnpm add -g pm2          # global
 
# WORKSPACE (monorepo) β€” pnpm-workspace.yaml
packages:
  - 'packages/*'
  - 'apps/*'
 
pnpm install             # Install semua workspace
pnpm -r run build        # Run build di semua package
pnpm --filter @myapp/ui build  # Run di package spesifik
 
# IMPORT DARI WORKSPACE
# package.json:
{
  "dependencies": {
    "@myapp/utils": "workspace:*"  # ← Link ke local package
  }
}
 
# BENCHMARK vs npm:
# Install 500 packages:
# npm:  120s
# yarn: 70s
# pnpm: 25s   (4.8x lebih cepat dari npm)
# bun:  8s    (15x lebih cepat dari npm)

Python Ecosystem β€” Evolusi dari pip sampai uv

Fragmentasi yang Membingungkan

MASALAH UNIK PYTHON: terlalu banyak tools, masing-masing solve subset masalah

MASALAH 1: Python version management
Tiap project butuh Python versi berbeda
β†’ Tools: pyenv, conda, asdf, mise, rtx

MASALAH 2: Virtual environment
Isolasi dependencies per project
β†’ Tools: venv (builtin), virtualenv, conda

MASALAH 3: Dependency management
Install, lock, resolve dependencies
β†’ Tools: pip, pip-tools, poetry, pipenv, pdm

MASALAH 4: Build & publish
Package project untuk PyPI
β†’ Tools: setuptools, build, flit, poetry, hatch

MASALAH 5: Script execution
Run script dengan dependencies inline
β†’ Tools: pipx, uvx

Sebelum uv: kamu butuh pyenv + venv + pip + pip-tools
            = 4 tools berbeda untuk masalah yang related

Setelah uv: uv handle SEMUA ini sekaligus

pip + venv β€” Yang Wajib Dipahami Dulu

# VIRTUAL ENVIRONMENT β€” mengapa wajib
python -m venv .venv                    # Buat virtual environment
source .venv/bin/activate               # Linux/Mac
.\.venv\Scripts\activate                # Windows
pip install requests                    # Install ke venv, bukan global
 
# TANPA venv: pip install ke global Python
# β†’ conflict antar project
# β†’ "works on my machine" problem
# β†’ tidak bisa isolasi versi berbeda
 
# pip fundamental
pip install requests==2.31.0            # Pin versi spesifik
pip install "requests>=2.28,<3.0"       # Version range
pip install -r requirements.txt         # Install dari file
pip freeze > requirements.txt           # Export yang terinstall
 
# MASALAH pip freeze:
# pip freeze output tidak membedakan:
# - Package yang kamu install langsung (direct dependency)
# - Package yang ter-install karena dependency lain (transitive)
# Solusi: pip-tools
 
# PIP-TOOLS β€” reproducible Python deps
pip install pip-tools
 
# requirements.in (hanya direct deps):
requests>=2.28
django>=4.2
 
# Generate lockfile:
pip-compile requirements.in             # β†’ requirements.txt (pinned, dengan semua transitive)
 
# Install dari lockfile:
pip-sync requirements.txt

Poetry β€” Sebelum uv Ada

# pyproject.toml (format standar modern)
[tool.poetry]
name = "my-project"
version = "0.1.0"
description = ""
 
[tool.poetry.dependencies]
python = "^3.11"
requests = "^2.31"
django = "^4.2"
 
[tool.poetry.group.dev.dependencies]
pytest = "^7.0"
black = "^23.0"
ruff = "^0.1"
poetry install          # Install + buat venv otomatis
poetry add requests     # Install + update pyproject.toml
poetry add -G dev pytest  # Dev dependency
poetry run python app.py  # Run dalam venv tanpa activate
poetry shell            # Aktivasi venv
poetry build            # Build package untuk publish
poetry publish          # Publish ke PyPI
 
# KELEBIHAN poetry:
# βœ… All-in-one: dependency + venv + build + publish
# βœ… pyproject.toml: format standar
# βœ… Lockfile (poetry.lock): reproducible
# βœ… Dependency groups (dev, test, docs terpisah)
 
# KEKURANGAN poetry:
# ❌ LAMBAT dibanding uv (Python-based, bukan Rust)
# ❌ Tidak mengelola Python version (butuh pyenv terpisah)
# ❌ Resolver kadang hang di project besar
# ❌ Ekosistem terpisah dari pip (kadang confusing)

Bun β€” Deep Dive

Bukan Hanya Package Manager

BUN = Runtime + Package Manager + Bundler + Test Runner + Transpiler
      Semuanya dalam satu binary (< 50MB)

DITULIS DALAM: Zig (bukan Rust!)
ENGINE: JavaScriptCore (Apple, sama yang dipakai Safari)
        bukan V8 (Chrome/Node.js)

MENGAPA Zig?
β†’ Zig punya kontrol memory sangat granular
β†’ Comptime (computation at compile time)
β†’ Bun bisa optimize per-platform saat compile
β†’ Lebih cepat dari Rust untuk beberapa workload I/O

MENGAPA JavaScriptCore?
β†’ JSC startup time jauh lebih cepat dari V8
β†’ JSC optimize berbeda dari V8 β€” bisa lebih cepat untuk some workloads
β†’ Tapi: V8 lebih battle-tested untuk server workload

Kenapa Bun Install Lebih Cepat

BENCHMARK (install Next.js project dari scratch):
npm:   87 detik
yarn:  67 detik
pnpm:  23 detik
bun:    6 detik  ← ~14x lebih cepat dari npm

TIGA ALASAN TEKNIS:

1. SYMLINK STORAGE (mirip pnpm):
   ~/.bun/install/cache/
   β†’ Satu file, satu copy di disk
   β†’ Symlink ke project, bukan copy

2. PARALEL ASYNC I/O:
   npm: download satu per satu (atau beberapa)
   bun: download SEMUA package sekaligus
        extract SEMUA sekaligus
        resolve SEMUA sekaligus
        pakai Zig's async I/O primitives

3. BINARY LOCKFILE (bun.lockb):
   npm: package-lock.json (JSON, perlu parse text)
   bun: bun.lockb (binary format)
   β†’ Baca lockfile = baca binary, jauh lebih cepat
   β†’ Tapi: tidak human-readable (butuh bun convert)

   bun bun.lockb  # Lihat isi lockfile dalam format readable

4. NATIVE IMPLEMENTATION:
   npm: Node.js (JavaScript process manage JavaScript install)
   bun: Zig + NAPI (native code manage install)
   β†’ Bun tidak punya overhead memulai JS engine untuk install

Bun sebagai Runtime

// bun run app.ts β€” langsung tanpa compile!
// TypeScript native, tidak perlu ts-node atau tsc
 
// Bun-specific APIs (tidak ada di Node.js):
const file = Bun.file("./data.json")
const json = await file.json() // ← built-in JSON file reader
 
// Bun.serve β€” HTTP server built-in
const server = Bun.serve({
  port: 3000,
  fetch(request: Request): Response {
    const url = new URL(request.url)
 
    if (url.pathname === "/") {
      return new Response("Hello World")
    }
 
    return new Response("Not Found", { status: 404 })
  },
})
 
// Bun Shell β€” run shell commands dari TypeScript
import { $ } from "bun"
 
const output = await $`ls -la`
console.log(output.text())
 
// Built-in SQLite
import { Database } from "bun:sqlite"
 
const db = new Database("mydb.sqlite")
const query = db.query("SELECT * FROM users WHERE id = $id")
const user = query.get({ $id: 1 })

Bun: Compatibility dan Gotchas

COMPATIBILITY STATUS (2026):
βœ… npm packages: 99%+ kompatibel
βœ… package.json scripts
βœ… Node.js core APIs (fs, path, http, crypto, dll)
βœ… CommonJS dan ESM
βœ… TypeScript, JSX native
βœ… .env file loading otomatis

GOTCHAS:
⚠️ Beberapa native addon (N-API) mungkin tidak kompatibel
⚠️ JavaScriptCore vs V8: behavior edge case bisa berbeda
   β†’ Kode yang bergantung pada V8-specific GC behavior: beware
⚠️ bun.lockb tidak human-readable
   β†’ Sulit review di PR
   β†’ Bun menyediakan: bun bun.lockb untuk print readable version
⚠️ Bun masih < 2 tahun mature β€” beberapa edge case belum tercover

KAPAN PAKAI BUN:
βœ… New project yang tidak butuh Node.js strict compatibility
βœ… Script dan tooling (build scripts, utilities)
βœ… API server di mana startup time penting (serverless)
βœ… CI/CD pipeline yang install npm packages (speed win)
βœ… Full-stack TypeScript dengan Bun runtime

KAPAN TIDAK PAKAI BUN:
❌ Legacy project dengan native addons spesifik
❌ Production yang butuh battle-tested stability
❌ Team yang belum familiar (learning curve)

uv β€” Deep Dive

Dari Astral (Pembuat Ruff)

UV = Universal Python package + project manager
DITULIS DALAM: Rust (sama seperti Ruff linter)
PEMBUAT: Astral (Charlie Marsh dan tim)

Astral philosophy:
"Developer tooling yang bergerak dengan kecepatan bahasa sistem"
β†’ Ruff: linter 10-100x lebih cepat dari flake8/pylint
β†’ uv: package manager 10-100x lebih cepat dari pip

BENCHMARK (install PyTorch + deps dari scratch):
pip:    120 detik
poetry: 90 detik
uv:     8 detik  ← ~15x lebih cepat dari pip

BENCHMARK (resolusi cold cache):
pip:    45 detik
uv:     0.8 detik

APA YANG DI-REPLACE uv:
pip          β†’ uv pip install / uv add
pip-tools    β†’ uv pip compile
pyenv        β†’ uv python install / uv python pin
virtualenv   β†’ uv venv
pipx         β†’ uvx (run tools tanpa install)
poetry       β†’ uv add, uv run, uv build (sebagian)

uv: Semua Perintah yang Perlu Diketahui

# ─── INSTALL UV ───────────────────────────────────────────────
curl -LsSf https://astral.sh/uv/install.sh | sh
# atau: pip install uv
 
# ─── PYTHON VERSION MANAGEMENT ────────────────────────────────
uv python install 3.12          # Download dan install Python 3.12
uv python install 3.11 3.12     # Install multiple
uv python list                  # Lihat Python yang tersedia
uv python pin 3.12              # Pin versi untuk project ini (.python-version)
uv run python --version         # Run dengan Python yang di-pin
 
# ─── PROJECT MANAGEMENT ───────────────────────────────────────
uv init my-project              # Buat project baru
cd my-project
uv add requests                 # Install + tambah ke pyproject.toml
uv add --dev pytest ruff        # Dev dependency
uv remove requests              # Hapus dependency
uv sync                         # Sync environment dengan pyproject.toml + lockfile
uv lock                         # Update lockfile tanpa install
uv run python app.py            # Run dalam project environment
uv run pytest                   # Run tool dalam environment
 
# ─── VIRTUAL ENVIRONMENT ──────────────────────────────────────
uv venv                         # Buat .venv di current directory
uv venv --python 3.11           # Dengan Python version spesifik
source .venv/bin/activate       # Activate (masih perlu untuk beberapa workflow)
 
# ─── PIP COMPATIBILITY ────────────────────────────────────────
# uv punya pip-compatible interface
uv pip install requests
uv pip install -r requirements.txt
uv pip freeze
uv pip compile requirements.in -o requirements.txt  # pip-tools compatible
 
# ─── GLOBAL TOOLS (pengganti pipx) ────────────────────────────
uvx ruff check .                # Run ruff tanpa install permanent
uvx black .                     # Run black tanpa install
uv tool install ruff            # Install sebagai global tool
uv tool list                    # Lihat installed tools
 
# ─── INLINE SCRIPT DEPENDENCIES (PEP 723) ─────────────────────
# Cara baru: dependencies di dalam script!
# script.py:
# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "requests",
#   "rich",
# ]
# ///
# import requests
# from rich import print
# ...
 
uv run script.py    # uv install deps, run, cleanup β€” semuanya otomatis

Kenapa uv Cepat β€” Mekanisme

ALASAN 1: PubGrub Resolution Algorithm (Rust implementation)
β†’ Algorithm dependency resolution terbaru (dikembangkan Dart/pub team)
β†’ Lebih efisien dari SAT solver yang dipakai poetry
β†’ Rust = zero-cost abstraction + no GC pause

ALASAN 2: Content-Addressable Cache
~/.cache/uv/
β”œβ”€β”€ wheels/           ← compiled wheel cache per versi
β”‚   └── sha256:abc123/
β”‚       └── requests-2.31.0-py3-none-any.whl
└── archives/         ← source distribution cache
    └── sha256:def456/

β†’ Package yang pernah didownload TIDAK pernah didownload lagi
β†’ Hash-based: kalau hash sama, file pasti sama
β†’ Multi-project share cache: install di project berbeda = instant

ALASAN 3: Parallel Everything
β†’ Resolve dependencies: parallel
β†’ Download wheels: parallel
β†’ Install: parallel
β†’ Rust async (tokio) untuk I/O concurrent

ALASAN 4: Pre-built Wheels
β†’ PyPI menyediakan pre-built binary wheel untuk most packages
β†’ uv prioritaskan wheel over source distribution
β†’ Tidak perlu compile C extension jika wheel tersedia

ALASAN 5: Lazy Dependency Graph
β†’ Tidak download SEMUA package info dulu
β†’ Lazy evaluation: hanya fetch apa yang dibutuhkan untuk resolve

uv: Compatibility

KOMPATIBEL DENGAN:
βœ… pip (drop-in replacement untuk most commands)
βœ… pyproject.toml (PEP 517/518/621)
βœ… requirements.txt
βœ… setup.py / setup.cfg (legacy)
βœ… conda environments (sebagian)
βœ… Virtual environments standard

TIDAK FULLY REPLACE:
⚠️ conda: uv tidak handle non-Python deps (CUDA, C libraries)
   β†’ Data science dengan GPU: conda masih diperlukan
⚠️ poetry publishing: uv build ada tapi publish masih beta
⚠️ conda environment: uv tidak baca environment.yml

KETERBATASAN:
❌ Non-PyPI package source (custom registry: bisa tapi setup extra)
❌ Conda packages (hanya pip-compatible packages)

Ekosistem Lain β€” Pembanding

Rust: Cargo β€” Standar Emas

# Cargo = BUILT-IN ke Rust, bukan afterthought
# Ini yang membuat banyak developer Rust happy
 
cargo new my-project        # Init project
cargo build                 # Compile
cargo run                   # Build + run
cargo test                  # Test
cargo bench                 # Benchmark
cargo doc                   # Generate documentation
cargo publish               # Publish ke crates.io
 
# Cargo.toml β€” single source of truth:
[package]
name = "my-project"
version = "0.1.0"
edition = "2021"
 
[dependencies]
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
 
[dev-dependencies]
criterion = "0.5"  # Hanya untuk test/benchmark
 
# KENAPA CARGO DIANGGAP TERBAIK:
# βœ… Satu tool untuk semua (build, test, doc, publish)
# βœ… Reproducible via Cargo.lock
# βœ… Workspace untuk monorepo built-in
# βœ… Features system (conditional compilation)
# βœ… Tidak ada dependency hell (setiap crate bisa punya versi berbeda)
# βœ… Integrated dengan rustup (toolchain management)
 
# KETERBATASAN:
# Compile time Rust sangat lama (bukan masalah cargo, tapi bahasa)
# Incremental compile membantu tapi masih lama untuk project besar

Go: Go Modules β€” Simpel tapi Opinionated

go mod init github.com/username/project
go get github.com/gin-gonic/gin@v1.9.0
go mod tidy      # hapus unused, download yang kurang
go mod download  # download semua deps tanpa install
go mod vendor    # vendoring: copy semua deps ke ./vendor
 
# go.mod β€” deklaratif:
module github.com/username/project
go 1.21
 
require (
    github.com/gin-gonic/gin v1.9.0
    github.com/stretchr/testify v1.8.4
)
 
# go.sum β€” lockfile (hash verification):
github.com/gin-gonic/gin v1.9.0 h1:ZAV...
github.com/gin-gonic/gin v1.9.0/go.mod h1:...
 
# KELEBIHAN:
# βœ… Built-in (tidak perlu install terpisah)
# βœ… Verifikasi hash (supply chain security)
# βœ… GOPATH dan module proxy (sum.golang.org)
 
# KEKURANGAN:
# ❌ Tidak ada version manager built-in (perlu asdf atau mise)
# ❌ Semantic versioning enforcement longgar
# ❌ Major version harus ganti import path (v2 = github.com/pkg/v2)

PHP: Composer β€” Mature tapi Lambat

composer init                  # Init project
composer require laravel/framework  # Install
composer require --dev phpunit/phpunit
composer install               # Install dari composer.lock
composer update                # Update semua
composer dump-autoload         # Regenerate autoloader
 
# composer.json:
{
    "require": {
        "php": ">=8.1",
        "laravel/framework": "^10.0"
    },
    "require-dev": {
        "phpunit/phpunit": "^10.0"
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        }
    }
}
 
# MASALAH COMPOSER:
# PHP-based = lambat (no Rust, no Zig)
# composer install di fresh: 30-60 detik untuk Laravel
# Solusi: composer install --prefer-dist --no-interaction (CI/CD flag)

Decision Matrix

Pilih Package Manager per Ekosistem

NODE.JS 2026:

New project:
β”œβ”€β”€ Prefer Bun if:
β”‚   β†’ TypeScript-first
β”‚   β†’ Tidak butuh strict Node.js compat
β”‚   β†’ Speed is priority (CI/CD)
β”‚   β†’ Personal project / startup
β”‚
β”œβ”€β”€ Prefer pnpm if:
β”‚   β†’ Monorepo
β”‚   β†’ Team yang sudah familiar
β”‚   β†’ Butuh strict Node.js compat
β”‚   β†’ Enterprise dengan banyak package
β”‚
└── Prefer npm if:
    β†’ Simplicity utama
    β†’ Semua developer familiar
    β†’ Legacy project maintenance

PYTHON 2026:

New project:
└── uv (hampir semua kasus kecuali data science)

Data science / ML:
└── conda (atau mamba) untuk handle CUDA + sistem library

Legacy project:
β”œβ”€β”€ Migrate ke uv jika mungkin
└── Tetap poetry/pip-tools jika ada custom workflow

Script one-off:
└── uvx atau uv run --with (PEP 723)

Perbandingan Kecepatan β€” Semua Ekosistem

INSTALL SPEED BENCHMARK (fresh install, 100+ packages):

Node.js:
npm:   100% (baseline)
yarn:   65%
pnpm:   25%
bun:     7%  ← 14x lebih cepat dari npm

Python:
pip:   100% (baseline)
poetry: 85%
pdm:    70%
uv:      5%  ← 20x lebih cepat dari pip

Rust:
cargo:  β€” (compiled language, different category)
       Compile time: sangat lama
       Dependency download: mirip pnpm (content-addressable)

Go:
go get: cukup cepat (binary download, tidak compile deps)

Pro/Con Summary Table

ManagerSpeedReliabilityDXCompatibilityMaturity
npmπŸ”΄ Lambatβœ… Stabilβœ… Familiarβœ… Universalβœ… 15 tahun
pnpm🟑 Cepatβœ… Stabilβœ… Baikβœ… Baikβœ… 7 tahun
yarn berry🟑 Cepat⚠️ Kadang issues⚠️ Beda mindset⚠️ Perlu check🟑 6 tahun
Bun🟒 Sangat cepat⚠️ Masih mudaβœ… All-in-oneβœ… 99%+⚠️ 2 tahun
pipπŸ”΄ Lambatβœ… StabilπŸ”΄ Manual setupβœ… Universalβœ… 15+ tahun
poetry🟑 OKβœ… Stabilβœ… Baikβœ… Baikβœ… 6 tahun
uv🟒 Sangat cepatβœ… Stabilβœ… All-in-oneβœ… pip-compat🟑 1.5 tahun
cargo🟒 Cepatβœ… Excellentβœ… Best-in-classβœ… Nativeβœ… 11 tahun
go mod🟒 Cepatβœ… Stabilβœ… Simpleβœ… Nativeβœ… 6 tahun

Setup CI/CD yang Optimal

# .github/workflows/ci.yml β€” dengan package manager caching
 
# NODE.JS dengan pnpm (recommended untuk production)
- name: Setup pnpm
  uses: pnpm/action-setup@v3
  with:
    version: 9
 
- name: Cache pnpm store
  uses: actions/cache@v4
  with:
    path: ~/.local/share/pnpm/store
    key: pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
    restore-keys: pnpm-
 
- name: Install dependencies
  run: pnpm install --frozen-lockfile # Equivalent npm ci
 
# NODE.JS dengan Bun (fastest CI)
- name: Setup Bun
  uses: oven-sh/setup-bun@v1
  with:
    bun-version: latest
 
- name: Cache Bun cache
  uses: actions/cache@v4
  with:
    path: ~/.bun/install/cache
    key: bun-${{ hashFiles('**/bun.lockb') }}
 
- name: Install
  run: bun install --frozen-lockfile
 
# PYTHON dengan uv (recommended)
- name: Install uv
  uses: astral-sh/setup-uv@v3
  with:
    enable-cache: true # Otomatis cache ~/.cache/uv
 
- name: Install Python
  run: uv python install 3.12
 
- name: Install dependencies
  run: uv sync --frozen # Equivalent pip-sync dari lockfile
 
- name: Run tests
  run: uv run pytest

Rekomendasi Konkret 2026

Node.js: Mulai project baru β†’ Bun. Existing project β†’ pnpm untuk migration yang aman.

Python: Apapun project barunya β†’ uv. Tidak ada alasan untuk tidak migrasi kecuali conda/GPU dependency.

Untuk portfolio kamu: ganti npm install di CI dengan Bun atau pnpm β†’ CI time bisa turun 5-10 menit untuk project Next.js.

Jangan Over-Engineer

Memilih package manager bukan architectural decision terbesar. Yang lebih penting: lockfile selalu di-commit ke git (reproducibility) dan CI pakai --frozen-lockfile / --locked (jangan biarkan CI update deps sendiri). Dua hal ini lebih penting dari pilihan antara npm, pnpm, atau Bun.


πŸ”— Lihat Juga


Package Manager Hierarchy | npm β†’ pnpm β†’ Bun Β· pip β†’ poetry β†’ uv Β· Cargo Β· Go Modules Β· PubGrub Β· Content-Addressable Storage Β· CI Caching