Home
Support Forums

Deployment fail (Next.JS and TypeScript)

Can’t seem to get it to work and get deployed, any assistance is greatly appreciated.

LOGS are bellow:

9:28:51 AM: Build ready to start
9:28:53 AM: build-image version: 53b83b6bede2920f236b25b6f5a95334320dc849
9:28:53 AM: build-image tag: v3.6.0
9:28:53 AM: buildbot version: 8ae026ef4905d9174e416775c6b64aa19950569b
9:28:53 AM: Building without cache
9:28:53 AM: Starting to prepare the repo for build
9:28:54 AM: No cached dependencies found. Cloning fresh repo
9:28:54 AM: git clone https://github.com/VodeniZeko/clock
9:28:55 AM: Preparing Git Reference refs/heads/main
9:28:56 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: β€˜dist’ versus β€˜dist/’ in the Netlify UI
9:28:56 AM: Starting build script
9:28:56 AM: Installing dependencies
9:28:56 AM: Python version set to 2.7
9:28:58 AM: v12.18.0 is already installed.
9:28:59 AM: Now using node v12.18.0 (npm v6.14.4)
9:28:59 AM: Started restoring cached build plugins
9:28:59 AM: Finished restoring cached build plugins
9:28:59 AM: Attempting ruby version 2.7.1, read from environment
9:29:01 AM: Using ruby version 2.7.1
9:29:02 AM: Using PHP version 5.6
9:29:02 AM: Started restoring cached node modules
9:29:02 AM: Finished restoring cached node modules
9:29:02 AM: Started restoring cached yarn cache
9:29:02 AM: Finished restoring cached yarn cache
9:29:02 AM: Installing yarn at version 1.22.4
9:29:02 AM: Installing Yarn!
9:29:02 AM: > Downloading tarball…
9:29:02 AM: % Total % Received % Xferd Average Speed Time Time Time Current
9:29:02 AM: Dload Upload Total Spent Left Speed
9:29:02 AM: 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
9:29:02 AM: 100 80 100 80 0 0 218 0 --:–:-- --:–:-- --:–:-- 218
9:29:02 AM: 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
9:29:02 AM: 100 93 100 93 0 0 130 0 --:–:-- --:–:-- --:–:-- 273
9:29:03 AM: 100 643 100 643 0 0 623 0 0:00:01 0:00:01 --:–:-- 623
9:29:03 AM: 4 1215k 4 50762 0 0 36684 0 0:00:33 0:00:01 0:00:32 36684
9:29:03 AM: 100 1215k 100 1215k 0 0 809k 0 0:00:01 0:00:01 --:–:-- 9881k
9:29:03 AM: [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.iw6e5pJf1T.asc
9:29:03 AM: 100 84 100 84 0 0 2974 0 --:–:-- --:–:-- --:–:-- 2974
9:29:03 AM: 100 97 100 97 0 0 1715 0 --:–:-- --:–:-- --:–:-- 1715
9:29:03 AM: 100 647 100 647 0 0 7188 0 --:–:-- --:–:-- --:–:-- 7188
9:29:03 AM: 100 1028 100 1028 0 0 7754 0 --:–:-- --:–:-- --:–:-- 7754
9:29:03 AM: > Verifying integrity…
9:29:03 AM: gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
9:29:03 AM: gpg: Good signature from β€œYarn Packaging yarn@dan.cx”
9:29:03 AM: gpg: WARNING: This key is not certified with a trusted signature!
9:29:03 AM: gpg: There is no indication that the signature belongs to the owner.
9:29:03 AM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907 BBB7 1646 B01B 86E5 0310
9:29:03 AM: Subkey fingerprint: 6D98 490C 6F1A CDDD 448E 4595 4F77 6793 6947 5BAA
9:29:03 AM: > GPG signature looks good
9:29:03 AM: > Extracting to ~/.yarn…
9:29:03 AM: > Adding to PATH... 9:29:04 AM: > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available. 9:29:04 AM: Installing NPM modules using Yarn version 1.22.4 9:29:05 AM: yarn install v1.22.4 9:29:05 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. 9:29:05 AM: [1/4] Resolving packages... 9:29:07 AM: [2/4] Fetching packages... 9:29:33 AM: info fsevents@2.1.3: The platform "linux" is incompatible with this module. 9:29:33 AM: info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation. 9:29:33 AM: info fsevents@1.2.13: The platform "linux" is incompatible with this module. 9:29:33 AM: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. 9:29:33 AM: [3/4] Linking dependencies... 9:29:44 AM: [4/4] Building fresh packages... 9:29:48 AM: success Saved lockfile. 9:29:48 AM: Done in 43.15s. 9:29:48 AM: NPM modules installed using Yarn 9:29:49 AM: Started restoring cached go cache 9:29:49 AM: Finished restoring cached go cache 9:29:49 AM: go version go1.14.4 linux/amd64 9:29:49 AM: go version go1.14.4 linux/amd64 9:29:49 AM: Installing missing commands 9:29:49 AM: Verify run directory 9:29:51 AM: ​ 9:29:51 AM: ──────────────────────────────────────────────────────────────── 9:29:51 AM: Netlify Build 9:29:51 AM: ──────────────────────────────────────────────────────────────── 9:29:51 AM: ​ 9:29:51 AM: ❯ Version 9:29:51 AM: @netlify/build 8.0.0 9:29:51 AM: ​ 9:29:51 AM: ❯ Flags 9:29:51 AM: deployId: 5fecb8d302cc090f7450ac75 9:29:51 AM: mode: buildbot 9:29:51 AM: ​ 9:29:51 AM: ❯ Current directory 9:29:51 AM: /opt/build/repo 9:29:51 AM: ​ 9:29:51 AM: ❯ Config file 9:29:51 AM: No config file was defined: using default values. 9:29:51 AM: ​ 9:29:51 AM: ❯ Context 9:29:51 AM: production 9:29:51 AM: ​ 9:29:51 AM: ──────────────────────────────────────────────────────────────── 9:29:51 AM: 1. Build command from Netlify app 9:29:51 AM: ──────────────────────────────────────────────────────────────── 9:29:51 AM: ​ 9:29:51 AM: yarn build
9:29:51 AM: yarn run v1.22.4
9:29:51 AM: $ next build
9:29:53 AM: warn - No build cache found. Please configure build caching for faster rebuilds.
9:29:53 AM: info - Creating an optimized production build…
9:30:21 AM: info - Compiled successfully
9:30:21 AM: info - Collecting page data…
9:30:23 AM: info - Generating static pages (0/4)
9:30:24 AM: info - Generating static pages (1/4)
9:30:25 AM: Error occurred prerendering page β€œ/SimpleCard”.
9:30:25 AM: TypeError: handleChange is not a function
9:30:25 AM: at SimpleCard (/opt/build/repo/.next/server/pages/SimpleCard.js:163:23)
9:30:25 AM: at d (/opt/build/repo/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:33:498)
9:30:25 AM: at bb (/opt/build/repo/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:16)
9:30:25 AM: at a.b.render (/opt/build/repo/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:42:43)
9:30:25 AM: at a.b.read (/opt/build/repo/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:83)
9:30:25 AM: at exports.renderToString (/opt/build/repo/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:52:138)
9:30:25 AM: at Object.renderPage (/opt/build/repo/node_modules/next/dist/next-server/server/render.js:53:851)
9:30:25 AM: at Function.getInitialProps (/opt/build/repo/.next/server/pages/_document.js:267:19)
9:30:25 AM: at loadGetInitialProps (/opt/build/repo/node_modules/next/dist/next-server/lib/utils.js:5:101)
9:30:25 AM: at renderToHTML (/opt/build/repo/node_modules/next/dist/next-server/server/render.js:53:1142)
9:30:25 AM: info - Generating static pages (2/4)
9:30:26 AM: { hours: 17, minutes: 30 }
9:30:26 AM: info - Generating static pages (3/4)
9:30:26 AM: { hours: 17, minutes: 30 }
9:30:26 AM: info - Generating static pages (4/4)
9:30:26 AM: > Build error occurred
9:30:26 AM: Error: Export encountered errors on following paths:
9:30:26 AM: /SimpleCard
9:30:26 AM: at exportApp (/opt/build/repo/node_modules/next/dist/export/index.js:30:1103)
9:30:26 AM: at processTicksAndRejections (internal/process/task_queues.js:97:5)
9:30:26 AM: at async /opt/build/repo/node_modules/next/dist/build/index.js:39:69
9:30:26 AM: at async /opt/build/repo/node_modules/next/dist/build/tracer.js:1:525
9:30:26 AM: error Command failed with exit code 1.
9:30:26 AM: ​
9:30:26 AM: ────────────────────────────────────────────────────────────────
9:30:26 AM: β€œbuild.command” failed
9:30:26 AM: ────────────────────────────────────────────────────────────────
9:30:26 AM: ​
9:30:26 AM: Error message
9:30:26 AM: Command failed with exit code 1: yarn build
9:30:26 AM: ​
9:30:26 AM: Error location
9:30:26 AM: In Build command from Netlify app:
9:30:26 AM: yarn build
9:30:26 AM: ​
9:30:26 AM: Resolved config
9:30:26 AM: build:
9:30:26 AM: command: yarn build
9:30:26 AM: commandOrigin: ui
9:30:26 AM: publish: /opt/build/repo/dist
9:30:26 AM: Caching artifacts
9:30:26 AM: Started saving node modules
9:30:26 AM: Finished saving node modules
9:30:26 AM: Started saving build plugins
9:30:26 AM: Finished saving build plugins
9:30:26 AM: Started saving yarn cache
9:30:26 AM: Finished saving yarn cache
9:30:26 AM: Started saving pip cache
9:30:26 AM: Finished saving pip cache
9:30:26 AM: Started saving emacs cask dependencies
9:30:26 AM: Finished saving emacs cask dependencies
9:30:26 AM: Started saving maven dependencies
9:30:26 AM: Finished saving maven dependencies
9:30:26 AM: Started saving boot dependencies
9:30:26 AM: Finished saving boot dependencies
9:30:26 AM: Started saving rust rustup cache
9:30:26 AM: Finished saving rust rustup cache
9:30:26 AM: Started saving rust cargo bin cache
9:30:26 AM: Finished saving rust cargo bin cache
9:30:26 AM: Started saving go dependencies
9:30:26 AM: Finished saving go dependencies
9:30:30 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:30:30 AM: Failing build: Failed to build site
9:30:30 AM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
9:30:30 AM: Finished processing build request in 1m36.374055646s

Hiya, sorry you are having trouble with your build.

This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem :slight_smile:

We also recommend trying to search the forums with the build error you encountered - it’s likely your question was already asked by someone else!

If you are still having problems, please provide as much information as you can on what you have already tried, what your build settings are, your package.json, etc. Thanks!

Hey @VodeniZeko :wave:t2:

From the looks of it, you’re treating SimpleCard as a component, rendered by the Popover page, but you’ve got SimpleCard.js in your ./pages/ directory, which Next.js will try to render as its own stand-alone page. Maybe pull it out of that directory and make one at the root called ./components, then adjust the import in Popover? SimpleCard depends on a couple of props and not having them present means the component can’t build. When Next.js attempts to build that component as its own page (instead of being rendered by another component), it gets no props and the page build fails.

Hope that makes sense!

–
Jon

@jonsully Thank you, you are correct I got around it by checking if !handleChange then return null.
I guess I have to learn more about Next.js, thank you again for taking the time to look thru the logs

No problem!

Technically speaking, when passing a handler to a child component in React you don’t want to directly pass an invocation of the function:

const parentClickHandler = () =>  {
  console.log('Clicky Clicky')
}

<ChildThing
  name="Hello there"
  handleClick={parentClickHandler()}
/>

Without getting too into it, that will cause a lot of problems. Generally speaking, you want to instead pass an inline function that calls your function:

const parentClickHandler = () =>  {
  console.log('Clicky Clicky')
}

<ChildThing
  name="Hello there"
  handleClick={() => parentClickHandler()}
/>

This will save you a lot of headaches in the future and would also fix the build issue (I think) since Next.js isn’t actually invoking the missing function at build time.

That said, by not pulling that component out to a separate directory, you are having Next build an (effectively-broken) page at https://your-url.example.com/simple-card etc.

Just food for thought!

Cheers!

1 Like