Build error occurred 1:00:28 AM: TypeError: Cannot add property target, object is not extensible

I’ve run out of ideas searching through the forums. Some posts reference react-scripts 5.0 but not using that framework. Using Yarn via yarn.lock and no errors or warnings until build.

Site name: adorable-boba-ab468d

Build log

12:58:33 AM: Waiting for other deploys from your team to complete. Check the queue: Netlify App
12:59:31 AM: build-image version: 68a2c262fa3c95a08a1716b8dde8fba0e332ec73 (focal)
12:59:31 AM: buildbot version: 68a2c262fa3c95a08a1716b8dde8fba0e332ec73
12:59:31 AM: Fetching cached dependencies
12:59:31 AM: Failed to fetch cache, continuing with build
12:59:31 AM: Starting to prepare the repo for build
12:59:31 AM: No cached dependencies found. Cloning fresh repo
12:59:31 AM: git clone --filter=blob:none git@bitbucket.org:pre-launch-landing-page/front-end-refresh
12:59:33 AM: Preparing Git Reference refs/heads/staging
12:59:33 AM: Parsing package.json dependencies
12:59:35 AM: Starting to install dependencies
12:59:35 AM: Python version set to 3.8
12:59:35 AM: Attempting Ruby version 2.7.2, read from environment
12:59:36 AM: Using Ruby version 2.7.2
12:59:36 AM: Started restoring cached go cache
12:59:36 AM: Finished restoring cached go cache
12:59:36 AM: Installing Go version 1.19.5 (requested 1.19.5)
12:59:41 AM: go version go1.19.5 linux/amd64
12:59:41 AM: Using PHP version 8.0
12:59:42 AM: v16.20.0 is already installed.
12:59:42 AM: Now using node v16.20.0 (npm v8.19.4)
12:59:42 AM: Enabling Node.js Corepack
12:59:42 AM: Started restoring cached build plugins
12:59:42 AM: Finished restoring cached build plugins
12:59:42 AM: Started restoring cached corepack dependencies
12:59:42 AM: Finished restoring cached corepack dependencies
12:59:42 AM: Started restoring cached yarn cache
12:59:42 AM: Finished restoring cached yarn cache
12:59:43 AM: No yarn workspaces detected
12:59:43 AM: Started restoring cached node modules
12:59:43 AM: Finished restoring cached node modules
12:59:43 AM: Installing npm packages using Yarn version 1.22.19
12:59:43 AM: yarn install v1.22.19
12:59:43 AM: [1/4] Resolving packages…
12:59:43 AM: [2/4] Fetching packages…
1:00:01 AM: [3/4] Linking dependencies…
1:00:15 AM: [4/4] Building fresh packages…
1:00:15 AM: Done in 31.49s.
1:00:15 AM: npm packages installed using Yarn
1:00:15 AM: Install dependencies script success
1:00:15 AM: Starting build script
1:00:16 AM: Detected 1 framework(s)
1:00:16 AM: “next” at version “12.3.4”
1:00:16 AM: Section completed: initializing
1:00:17 AM: ​
1:00:17 AM: Netlify Build
1:00:17 AM: ────────────────────────────────────────────────────────────────
1:00:17 AM: ​
1:00:17 AM: ❯ Version
1:00:17 AM: @netlify/build 29.9.2
1:00:17 AM: ​
1:00:17 AM: ❯ Flags
1:00:17 AM: baseRelDir: true
1:00:17 AM: buildId: 64454799318b6d00083ab42b
1:00:17 AM: deployId: 64454799318b6d00083ab42d
1:00:17 AM: ​
1:00:17 AM: ❯ Current directory
1:00:17 AM: /opt/build/repo
1:00:17 AM: ​
1:00:17 AM: ❯ Config file
1:00:17 AM: No config file was defined: using default values.
1:00:17 AM: ​
1:00:17 AM: ❯ Context
1:00:17 AM: branch-deploy
1:00:17 AM: ​
1:00:17 AM: ❯ Installing plugins
1:00:17 AM: - @netlify/plugin-nextjs@4.35.0
1:00:26 AM: ​
1:00:26 AM: ❯ Using Next.js Runtime - v4.35.0
1:00:28 AM: ​
1:00:28 AM: 1. @netlify/plugin-nextjs (onPreBuild event)
1:00:28 AM: ────────────────────────────────────────────────────────────────
1:00:28 AM: ​
1:00:28 AM: No Next.js cache to restore.
1:00:28 AM: Netlify configuration property “build.environment.NEXT_PRIVATE_TARGET” value changed.
1:00:28 AM: ​
1:00:28 AM: (@netlify/plugin-nextjs onPreBuild completed in 14ms)
1:00:28 AM: ​
1:00:28 AM: 2. Build command from Netlify app
1:00:28 AM: ────────────────────────────────────────────────────────────────
1:00:28 AM: ​
1:00:28 AM: $ yarn build
1:00:28 AM: yarn run v1.22.19
1:00:28 AM: $ next build
1:00:28 AM: > Build error occurred
1:00:28 AM: TypeError: Cannot add property target, object is not extensible
1:00:28 AM: at Object.loadConfig [as default] (/opt/build/repo/node_modules/next/dist/server/config.js:103:31)
1:00:28 AM: at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:79:20)
1:00:28 AM: at async /opt/build/repo/node_modules/next/dist/build/index.js:69:28
1:00:28 AM: at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:79:20)
1:00:28 AM: at async Object.build [as default] (/opt/build/repo/node_modules/next/dist/build/index.js:65:29)
1:00:28 AM: error Command failed with exit code 1. (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
1:00:28 AM: info Visit yarn run | Yarn for documentation about this command.
1:00:28 AM: ​
1:00:28 AM: “build.command” failed
1:00:28 AM: ────────────────────────────────────────────────────────────────
1:00:28 AM: ​
1:00:28 AM: Error message
1:00:28 AM: Command failed with exit code 1: yarn build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
1:00:28 AM: ​
1:00:28 AM: Error location
1:00:28 AM: In Build command from Netlify app:
1:00:28 AM: yarn build
1:00:28 AM: ​
1:00:28 AM: Resolved config
1:00:28 AM: build:
1:00:28 AM: command: yarn build
1:00:28 AM: commandOrigin: ui
1:00:28 AM: environment:
1:00:28 AM: - NEXT_PUBLIC_BASE_URL
1:00:28 AM: - NEXT_PUBLIC_GA_MEASUREMENT_ID
1:00:28 AM: - NEXT_PUBLIC_SITE_KEY
1:00:28 AM: - NPM_FLAGS
1:00:28 AM: - NEXT_PRIVATE_TARGET
1:00:28 AM: publish: /opt/build/repo/.next
1:00:28 AM: publishOrigin: ui
1:00:28 AM: plugins:
1:00:28 AM: - inputs: {}
1:00:28 AM: origin: ui
1:00:28 AM: package: ‘@netlify/plugin-nextjs’
1:00:29 AM: Caching artifacts
1:00:29 AM: Started saving node modules
1:00:29 AM: Finished saving node modules
1:00:29 AM: Started saving build plugins
1:00:29 AM: Finished saving build plugins
1:00:29 AM: Started saving corepack cache
1:00:29 AM: Finished saving corepack cache
1:00:29 AM: Started saving yarn cache
1:00:32 AM: Finished saving yarn cache
1:00:32 AM: Started saving pip cache
1:00:32 AM: Finished saving pip cache
1:00:32 AM: Started saving emacs cask dependencies
1:00:32 AM: Finished saving emacs cask dependencies
1:00:32 AM: Started saving maven dependencies
1:00:32 AM: Finished saving maven dependencies
1:00:32 AM: Started saving boot dependencies
1:00:32 AM: Finished saving boot dependencies
1:00:32 AM: Started saving rust rustup cache
1:00:32 AM: Finished saving rust rustup cache
1:00:32 AM: Started saving go dependencies
1:00:32 AM: Finished saving go dependencies
1:00:33 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:00:33 AM: Failing build: Failed to build site
1:00:33 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
1:00:33 AM: Finished processing build request in 1m2.543s

image

That doesn’t look much like a Netlify issue. Does this build locally? Not yarn dev but yarn build.

If yes, could you share a minimal reproduction repo so we can test it?

Thank you for responding. It builds locally without issues using yarn build.

Here’s a repo for testing: Bitbucket

Was this the right information for what you need to test?

There’s one known issue that may be causing this but my scenario doesn’t exactly match the associated post: [Support Guide] Netlify app builds locally but fails on deploy (case sensitivity)

Does anyone know if all files must be lower case for Netlify to builds to work? Or is it simply that the references must match the filename?

My application has some files with uppercase, however imports match the case.

Correct, the reference must match the directory and filename e.g. *the following are all different

  • /directory/filename.js
  • /directory/Filename.js
  • /Directory/filename.js
  • /Directory/Filename.js

However I don’t believe this is anything to do with filename case. Here’s a couple of thread I found searching the interwebs

Finally solved it. I had to add ‘node’: true to .eslintrc.js

Turns out I’d accidentally applied a quick fix to next.config.js due to a lint error. To fix the lint error I had to edit .eslintrcs.js to the below:

'env': {
    'browser': true,
    'es2021': true,
    'jest': true,
    'node': true
  },```

Hi @SimonSays :wave:t6:

Thanks for sharing the solution with the community this is helpful!