Tooling Vite Npm Pnpm Npx
3 min readTooling — Vite, npm, pnpm, npx
Senior interviews often probe whether you understand what runs when, what bundles what, and why your tooling choices matter for DX, CI speed, and production performance.
Vite (what it is)
Vite is a modern frontend build tool that provides:
- A dev server with fast startup and HMR (Hot Module Replacement)
- A production build pipeline (bundling + code splitting + asset processing)
How it works (high level):
- Dev: serves native ESM modules and transforms on demand (fast feedback loop).
- Build: bundles for production (typically via Rollup under the hood).
When to use Vite:
- Most modern React/Vue/Svelte apps and many Angular-adjacent tooling setups.
- When you want fast dev iteration + good production output without heavy config.
Common Vite concepts to know:
vite dev(ornpm run dev) → dev servervite build→ production buildvite preview→ serve the built output locallyvite.config.ts→ plugins, aliasing, build options- Env vars:
import.meta.env(notprocess.envby default)
npm (what it is)
npm is:
- A package registry (hosted at npmjs.com) and
- A package manager + CLI (
npm) used to install dependencies and run scripts.
Key files:
package.json— dependencies + scriptspackage-lock.json— lockfile pinning exact versions for reproducible installs
Common commands:
npm install— install depsnpm ci— clean, reproducible install in CI (uses lockfile strictly)npm run <script>— runpackage.jsonscripts
When to prefer npm ci:
- In CI pipelines for deterministic installs and speed.
pnpm (what it is)
pnpm is an alternative package manager focused on:
- Disk efficiency (content-addressable store)
- Speed (especially in monorepos)
- Strictness (helps catch “phantom dependency” issues)
Key files:
pnpm-lock.yaml— pnpm lockfile
Why teams choose pnpm:
- Monorepos with lots of packages (better install performance and caching).
- More deterministic dependency access patterns (good for large teams).
Useful pnpm commands:
pnpm installpnpm -r <cmd>(recursive across workspaces)pnpm dlx <pkg>(likenpx, runs a package without permanent install)
Version management tip:
- Use
corepackto pin pnpm versions across machines/CI.
npx (what it is)
npx runs package binaries without you manually installing them globally.
Typical use cases:
- Run project-local CLIs (e.g.,
npx eslint .,npx playwright test) - Run one-off tools (e.g.,
npx serve .)
Modern equivalents:
npm exec <cmd>(preferred in some setups)pnpm dlx <pkg>(pnpm equivalent for one-offs)
How these fit together (interview-ready)
- Vite builds/serves your frontend app.
- npm/pnpm install dependencies and run scripts that call Vite (and other tooling).
- npx is a convenient runner for CLIs (especially ad-hoc).
Good senior rule of thumb:
Pick one package manager per repo (npm or pnpm), commit the lockfile, and use CI-friendly install commands (
npm ci/ pnpm equivalents).
Common pitfalls (and strong answers)
- “Works on my machine” installs: mismatched lockfiles, using
npm installin CI. - Fix: commit lockfile, use
npm ci(or pnpm lock + strict install) in CI.
- Dependency confusion: importing packages that aren’t declared (phantom deps).
- Fix: declare deps properly; pnpm tends to expose this earlier.
- Env var confusion: expecting Node-style
process.envin Vite. - Fix: use
import.meta.envand Vite’s env prefixing rules.
Questions & Answers
A: Prefer Vite for modern app development where fast dev server/HMR and simpler config matter; use Webpack when legacy ecosystems/plugins or highly customized bundling requirements demand it.
npm install and npm ci?A: npm ci is designed for CI: it installs exactly from package-lock.json, is faster, and fails if the lockfile and package.json are out of sync.
npx do?A: It runs package binaries (project-local or fetched on demand) without requiring a global install, e.g., npx eslint . or npx serve ..
A: Better install speed/disk usage in large repos and stricter dependency resolution that prevents relying on undeclared dependencies.