Search code examples
next.jsvercel

Cannot deploy Next.js app on Vercel: "Command 'npm run build' exited with 1" error


I’m trying to deploy my Next.js app on Vercel, but I keep getting the following error during the build process:

[19:28:17.976] Running build in Washington, D.C., USA (East) – iad1
[19:28:18.284] Cloning github.com/IslamAbukoush/Quant_Apps_Next (Branch: main, Commit: 2efab9d)
[19:28:18.695] Previous build cache not available
[19:28:20.829] Cloning completed: 2.544s
[19:28:21.212] Running "vercel build"
[19:28:21.705] Vercel CLI 39.3.0
[19:28:22.082] Installing dependencies...
[19:28:45.626] 
[19:28:45.627] added 545 packages in 23s
[19:28:45.627] 
[19:28:45.627] 170 packages are looking for funding
[19:28:45.628]   run `npm fund` for details
[19:28:45.732] Detected Next.js version: 15.1.5
[19:28:45.740] Running "npm run build"
[19:28:45.867] 
[19:28:45.867] > [email protected] build
[19:28:45.867] > npm i && next build
[19:28:45.867] 
[19:28:47.343] 
[19:28:47.344] up to date, audited 318 packages in 1s
[19:28:47.345] 
[19:28:47.345] 64 packages are looking for funding
[19:28:47.345]   run `npm fund` for details
[19:28:47.345] 
[19:28:47.346] found 0 vulnerabilities
[19:28:51.465] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[19:28:51.467] This information is used to shape Next.js' roadmap and prioritize features.
[19:28:51.467] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[19:28:51.467] https://nextjs.org/telemetry
[19:28:51.467] 
[19:28:51.612]    ▲ Next.js 15.1.5
[19:28:51.613] 
[19:28:51.640]    Creating an optimized production build ...
[19:29:14.430]  ✓ Compiled successfully
[19:29:14.436]    Skipping linting
[19:29:14.436]    Checking validity of types ...
[19:29:14.605] Error: Command "npm run build" exited with 1

This issue does not happen locally, where I can build without any problems, and npm run lint returns no errors either. Here's my package.json:

{
  "name": "youtube-language-tuto",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev --turbopack",
    "build": "npm i && next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@emailjs/browser": "^4.4.1",
    "@emotion/cache": "^11.14.0",
    "@emotion/react": "^11.14.0",
    "@emotion/styled": "^11.14.0",
    "@hookform/resolvers": "^3.9.1",
    "@mui/icons-material": "^6.3.0",
    "@mui/joy": "^5.0.0-beta.51",
    "@mui/material": "^6.4.0",
    "@mui/styles": "^6.4.0",
    "@radix-ui/react-label": "^2.1.0",
    "@radix-ui/react-select": "^2.1.2",
    "@radix-ui/react-slot": "^1.1.0",
    "class-variance-authority": "^0.7.0",
    "clsx": "^2.1.1",
    "lucide-react": "^0.460.0",
    "next": "^15.1.4",
    "next-intl": "^3.26.3",
    "quant-app": "file:",
    "quant-apps-ui": "file:",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-hook-form": "^7.53.2",
    "react-i18next": "^15.4.0",
    "react-router-dom": "^7.1.1",
    "swipe": "^1.7.7",
    "swiper": "^11.2.1",
    "tailwind-merge": "^2.5.4",
    "tailwindcss-animate": "^1.0.7",
    "uuid": "^11.0.4",
    "youtube-language-tuto": "file:",
    "zod": "^3.23.8"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "eslint": "9.18.0",
    "eslint-config-next": "15.1.5",
    "postcss": "^8",
    "tailwindcss": "^3.4.1",
    "typescript": "^5"
  }
}

Things I’ve tried:

  • Removed .next, node_modules, and package-lock.json, and ran npm install again.
  • Disabled ESLint during the build.
  • Set CI to false in environment variables.
  • Deleted package-lock.json

None of these have worked. Has anyone encountered a similar issue or can provide suggestions on what might be causing this error?

Edit:

I tried disabling type checking as well, but still no luck:

const nextConfig: NextConfig = {
    eslint: {
        ignoreDuringBuilds: true,
    },
    typescript: {
        ignoreBuildErrors: true,
    },
};

Vercel output:

[19:56:43.569] Running build in Washington, D.C., USA (East) – iad1
[19:56:45.228] Cloning github.com/IslamAbukoush/Quant_Apps_Next (Branch: main, Commit: d463913)
[19:56:46.776] Previous build cache not available
[19:56:48.915] Cloning completed: 3.687s
[19:56:49.524] Running "vercel build"
[19:56:50.068] Vercel CLI 39.3.0
[19:56:50.407] Installing dependencies...
[19:57:36.083] 
[19:57:36.083] added 537 packages in 45s
[19:57:36.083] 
[19:57:36.083] 168 packages are looking for funding
[19:57:36.083]   run `npm fund` for details
[19:57:36.171] Detected Next.js version: 15.1.5
[19:57:36.177] Running "npm run build"
[19:57:36.302] 
[19:57:36.302] > [email protected] build
[19:57:36.303] > npm i && next build
[19:57:36.303] 
[19:57:40.388] 
[19:57:40.388] added 3 packages, and audited 318 packages in 4s
[19:57:40.388] 
[19:57:40.388] 64 packages are looking for funding
[19:57:40.389]   run `npm fund` for details
[19:57:40.391] 
[19:57:40.391] found 0 vulnerabilities
[19:57:41.847] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[19:57:41.848] This information is used to shape Next.js' roadmap and prioritize features.
[19:57:41.849] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[19:57:41.849] https://nextjs.org/telemetry
[19:57:41.849] 
[19:57:42.026]    ▲ Next.js 15.1.5
[19:57:42.027] 
[19:57:42.125]    Creating an optimized production build ...
[19:58:04.588]  ✓ Compiled successfully
[19:58:04.601]    Skipping validation of types
[19:58:04.602]    Skipping linting
[19:58:04.752] Error: Command "npm run build" exited with 1
[19:58:07.089] 

Solution

  • After spending a lot of time debugging, I solved the issue by changing "build" in package.json to the default command of: "build": "next build".

    It seems that npm i was causing an issue.