'Netlify deploy error: Deploy did not succeed: Deploy directory 'build' does not exist
I know this is a common error, but I tried a lot of solutions and no one did fix this problem. What am I doing wrong?
The project is in NextJs, I have already tried theses different commands on Netlify:
CI = npm run build
npm run build
CI=npm run build
7:22:05 PM: ──────────────────────────────────────────────────────────────── 7:22:05 PM: 2. Deploy site 7:22:05 PM: ──────────────────────────────────────────────────────────────── 7:22:05 PM: 7:22:05 PM: 7:22:05 PM: ──────────────────────────────────────────────────────────────── 7:22:05 PM: Configuration error 7:22:05 PM: ──────────────────────────────────────────────────────────────── 7:22:05 PM: 7:22:05 PM: Error message 7:22:05 PM: Deploy did not succeed: Deploy directory 'build' does not exist 7:22:05 PM: 7:22:05 PM: Resolved config 7:22:05 PM: build: 7:22:05 PM: command: CI='' npm run build 7:22:05 PM: commandOrigin: ui 7:22:05 PM: publish: /opt/build/repo/build 7:22:05 PM: publishOrigin: ui 7:22:05 PM: Caching artifacts 7:22:05 PM: Started saving node modules 7:22:05 PM: Finished saving node modules 7:22:05 PM: Started saving build plugins 7:22:05 PM: Finished saving build plugins 7:22:05 PM: Started saving pip cache 7:22:05 PM: Finished saving pip cache 7:22:05 PM: Started saving emacs cask dependencies 7:22:06 PM: Finished saving emacs cask dependencies 7:22:06 PM: Started saving maven dependencies 7:22:07 PM: Creating deploy upload records 7:22:06 PM: Finished saving maven dependencies 7:22:06 PM: Started saving boot dependencies 7:22:06 PM: Finished saving boot dependencies 7:22:06 PM: Started saving rust rustup cache 7:22:06 PM: Finished saving rust rustup cache 7:22:08 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2) 7:22:06 PM: Started saving go dependencies 7:22:06 PM: Finished saving go dependencies 7:22:07 PM: Build failed due to a user error: Build script returned non-zero exit code: 2 7:22:08 PM: Failing build: Failed to build site 7:22:08 PM: Finished processing build request in 57.858418183s
Here's my package.json:
{
"name": "mynextjsproject",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"aos": "^2.3.4",
"jquery": "^3.6.0",
"next": "12.1.6",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-icons": "^4.3.1",
"swiper": "^8.1.4"
},
"devDependencies": {
"autoprefixer": "^10.4.7",
"eslint": "8.15.0",
"eslint-config-next": "12.1.6",
"postcss": "^8.4.13",
"tailwindcss": "^3.0.24"
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|