Netlify build fails Algolia crawler integration

Site name

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"
  }
}

Changing the build script in the package.json to "build": "CI= npm run build", doubled the build times. They would eventually fail with the error message: build exceeded memory limits So, I reverted the build script back to "build": "next build", (and the build is still failing with the original error message, which you can see in my first post). Could this be an issue with Next 14?

Checking your latest build: Deploy details | Deploys | nextjs-royal-ridges | Netlify, the error is here:

Looks like an rror with your code than Netlify.

1 Like

First off thank you very much @hrishikesh I went straight to the red text and missed that error message.

The error was being caused by the use of the to prop within next/link when it should have been href. Kind of a strange error message for a wrong prop type… :man_shrugging:t2: