Vercel build fails: Command "npm run build" exited with 1 (works locally)
#148Error
Error: Command "npm run build" exited with 1 on Vercel, while the build passes on my machine
Why it happens, and why this works
Vercel builds on clean Linux with only committed files and configured env vars, so anything that depends on your machine (case-insensitive file system, a local .env, global tools, a different Node) breaks there. The real cause is the first error printed above the exit-code line.
Fix
The exit code is a wrapper; scroll UP in the build log to the first real error, then check the usual local-vs-Vercel differences. 1. Case-sensitive imports: Linux fails import './Components/Button' when the file is components/button.jsx (Windows/Mac don't care). Match the exact case; to rename only the case use git mv. 2. Missing env vars: add them in Project Settings → Environment Variables for Production AND Preview, then redeploy. 3. Lockfile/Node mismatch: commit package-lock.json (or pnpm-lock), and set the Node version (engines.node in package.json or Project Settings). 4. Lint/type errors: next build fails on ESLint/TS errors that dev mode ignores; run npm run build locally to reproduce and fix them (don't turn the checks off). 5. Dependencies only in your global install (tsc, a CLI) must be in package.json devDependencies.
Did it work?
No reports yetRelated fixes
git push rejected: Updates were rejected because the remote contains work that you do not have locally
#81! [rejected] main -> main (fetch first) error: failed to push some refs hint: Updates were rejected because the remote contains work that you do not have locally.
npm error Missing script: "dev"
#83npm error Missing script: "dev" npm error To see a list of scripts, run: npm error npm run
npm publish of a new package fails with 404 Not Found on PUT, then 403 two-factor required
#21npm publish fails: 404 Not Found - PUT https://registry.npmjs.org/<package> - Not found. "could not be found or you do not have permission to access it" (first publish of a new package). After logging in again: 403 Forbidden - Two-factor authentication or granular access token with bypass 2fa enabled is required to publish packages.