I came across this post and tried CI=npm run build
and the build still failed after 5m27s of trying.
The builds were going fine but then randomly started failing build after I pushed unrelated code (page updates) to the repo.
The full error is as follows:
11:13:41 AM: "build.command" failed
11:13:41 AM: ────────────────────────────────────────────────────────────────
11:13:41 AM:
11:13:41 AM: Error message
11:13:41 AM: Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
11:13:41 AM:
11:13:41 AM: Error location
11:13:41 AM: In Build command from Netlify app:
11:13:41 AM: npm run build
11:13:41 AM:
11:13:41 AM: Resolved config
11:13:41 AM: build:
11:13:41 AM: command: npm run build
11:13:41 AM: commandOrigin: ui
11:13:41 AM: environment:
11:13:41 AM: - ALGOLIA_API_KEY
11:13:41 AM: - ALGOLIA_BASE_URL
11:13:41 AM: - NEXT_PRIVATE_TARGET
11:13:41 AM: publish: /opt/build/repo/.next
11:13:41 AM: publishOrigin: ui
11:13:41 AM: plugins:
11:13:41 AM: - inputs: {}
11:13:41 AM: origin: ui
11:13:41 AM: package: "@netlify/plugin-nextjs"
11:13:41 AM: - inputs: {}
11:13:41 AM: origin: ui
11:13:41 AM: package: "@netlify/plugin-lighthouse"
11:13:41 AM: - inputs: {}
11:13:41 AM: origin: ui
11:13:41 AM: package: "@algolia/netlify-plugin-crawler"
11:13:42 AM: Failed during stage "building site": Build script returned non-zero exit code: 2
11:13:42 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:13:42 AM: Failing build: Failed to build site
11:13:42 AM: Finished processing build request in 30.977s
When I setup the Netlify Integration “Algolia Crawler” it created the following environmental variables:
ALGOLIA_API_KEY && ALGOLIA_BASE_URL
However, I do not see the NEXT_PRIVATE_TARGET
in the environmental variables…
This is my full package.json
{
"name": "nextjs_royal_ridges",
"version": "0.1.0",
"private": false,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@headlessui/react": "^0.0.0-insiders.bfacb64",
"@heroicons/react": "^2.0.18",
"@tailwindcss/typography": "^0.5.10",
"next": "^14.0.1",
"react": "^18",
"react-dom": "^18",
"tailwindcss-hero-patterns": "^0.1.2"
},
"devDependencies": {
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.0.1",
"postcss": "^8",
"tailwindcss": "^3.3.0"
}
}