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
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!
I have searched the forumβ¦ the build works fine on localhost and works on vercel platform but for some reason does not work on Netlifyβ¦
I manage to sort out the webpack error but now have different one:
1:41:11 AM: Build ready to start
1:41:12 AM: build-image version: d84c79427e8f83c1ba17bcdd7b3fe38059376b68
1:41:12 AM: build-image tag: v3.6.1
1:41:12 AM: buildbot version: df42d44cc6a0381cf657a671baf049c03981bafe
1:41:12 AM: Building without cache
1:41:12 AM: Starting to prepare the repo for build
1:41:13 AM: No cached dependencies found. Cloning fresh repo
1:41:13 AM: git clone git@gitlab.com:pl-starters/nextjs-mui
1:41:14 AM: Preparing Git Reference refs/heads/master
1:41:16 AM: Starting build script
1:41:16 AM: Installing dependencies
1:41:16 AM: Python version set to 2.7
1:41:18 AM: v12.18.0 is already installed.
1:41:18 AM: Now using node v12.18.0 (npm v6.14.4)
1:41:18 AM: Started restoring cached build plugins
1:41:18 AM: Finished restoring cached build plugins
1:41:18 AM: Attempting ruby version 2.7.1, read from environment
1:41:20 AM: Using ruby version 2.7.1
1:41:20 AM: Using PHP version 5.6
1:41:20 AM: Started restoring cached node modules
1:41:20 AM: Finished restoring cached node modules
1:41:20 AM: Started restoring cached yarn cache
1:41:20 AM: Finished restoring cached yarn cache
1:41:20 AM: Installing yarn at version 1.22.4
1:41:20 AM: Installing Yarn!
1:41:20 AM: > Downloading tarball...
1:41:20 AM: [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.01NvLQbY3G
1:41:20 AM: % Total % Received % Xferd Average Speed Time Time Time Current
1:41:20 AM: Dload Upload Total Spent Left Speed
1:41:20 AM: 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
1:41:20 AM: 100 80 100 80 0 0 366 0 --:--:-- --:--:-- --:--:-- 366
1:41:21 AM: 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
1:41:21 AM: 100 93 100 93 0 0 150 0 --:--:-- --:--:-- --:--:-- 659
1:41:21 AM: 100 625 100 625 0 0 704 0 --:--:-- --:--:-- --:--:-- 704
1:41:21 AM: 100 1215k 100 1215k 0 0 935k 0 0:00:01 0:00:01 --:--:-- 935k
1:41:21 AM: [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.01NvLQbY3G.asc
1:41:22 AM: 100 84 100 84 0 0 1529 0 --:--:-- --:--:-- --:--:-- 1529
1:41:22 AM: 100 97 100 97 0 0 1179 0 --:--:-- --:--:-- --:--:-- 1179
1:41:22 AM: 100 629 100 629 0 0 5522 0 --:--:-- --:--:-- --:--:-- 5522
1:41:22 AM: 0 1028 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
1:41:22 AM: 100 1028 100 1028 0 0 5610 0 --:--:-- --:--:-- --:--:-- 1003k
1:41:22 AM: > Verifying integrity...
1:41:22 AM: gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
1:41:22 AM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
1:41:22 AM: gpg: Note: This key has expired!
1:41:22 AM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907 BBB7 1646 B01B 86E5 0310
1:41:22 AM: Subkey fingerprint: 6D98 490C 6F1A CDDD 448E 4595 4F77 6793 6947 5BAA
1:41:22 AM: > GPG signature looks good
1:41:22 AM: > Extracting to ~/.yarn...
1:41:22 AM: > Adding to $PATH...
1:41:22 AM: > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
1:41:23 AM: Installing NPM modules using Yarn version 1.22.4
1:41:23 AM: yarn install v1.22.4
1:41:23 AM: [1/4] Resolving packages...
1:41:23 AM: [2/4] Fetching packages...
1:41:33 AM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
1:41:33 AM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
1:41:33 AM: [3/4] Linking dependencies...
1:41:37 AM: [4/4] Building fresh packages...
1:41:41 AM: Done in 17.68s.
1:41:41 AM: NPM modules installed using Yarn
1:41:41 AM: Started restoring cached go cache
1:41:41 AM: Finished restoring cached go cache
1:41:41 AM: go version go1.14.4 linux/amd64
1:41:41 AM: go version go1.14.4 linux/amd64
1:41:41 AM: Installing missing commands
1:41:41 AM: Verify run directory
1:41:43 AM: β
1:41:43 AM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1:41:43 AM: Netlify Build
1:41:43 AM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1:41:43 AM: β
1:41:43 AM: β― Version
1:41:43 AM: @netlify/build 9.1.3
1:41:43 AM: β
1:41:43 AM: β― Flags
1:41:43 AM: deployId: 60305aa7e88b4e6e893bf81e
1:41:43 AM: mode: buildbot
1:41:43 AM: β
1:41:43 AM: β― Current directory
1:41:43 AM: /opt/build/repo
1:41:43 AM: β
1:41:43 AM: β― Config file
1:41:43 AM: No config file was defined: using default values.
1:41:43 AM: β
1:41:43 AM: β― Context
1:41:43 AM: production
1:41:43 AM: β
1:41:43 AM: β― Installing plugins
1:41:43 AM: - @netlify/plugin-nextjs@2.0.1
1:42:02 AM: β
1:42:02 AM: β― Loading plugins
1:42:02 AM: - @netlify/plugin-nextjs@2.0.1 from Netlify app
1:42:02 AM: β
1:42:02 AM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1:42:02 AM: 1. onPreBuild command from @netlify/plugin-nextjs
1:42:02 AM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1:42:02 AM: β
1:42:02 AM: β
1:42:02 AM: (@netlify/plugin-nextjs onPreBuild completed in 8ms)
1:42:02 AM: β
1:42:02 AM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1:42:02 AM: 2. Build command from Netlify app
1:42:02 AM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1:42:02 AM: β
1:42:02 AM: $ next build
1:42:03 AM: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://err.sh/next.js/no-cache
1:42:03 AM: info - Creating an optimized production build...
1:42:38 AM: Failed to compile.
1:42:38 AM:
1:42:38 AM: ModuleNotFoundError: Module not found: Error: Can't resolve 'pnpapi' in '/opt/build/repo/node_modules/pnp-webpack-plugin'
1:42:38 AM: > Build error occurred
1:42:38 AM: Error: > Build failed because of webpack errors
1:42:38 AM: at /opt/build/repo/node_modules/next/dist/build/index.js:15:918
1:42:38 AM: at runMicrotasks (<anonymous>)
1:42:38 AM: at processTicksAndRejections (internal/process/task_queues.js:97:5)
1:42:38 AM: at async /opt/build/repo/node_modules/next/dist/build/tracer.js:3:470
1:42:38 AM: β
1:42:38 AM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1:42:38 AM: "build.command" failed
1:42:38 AM: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1:42:38 AM: β
1:42:38 AM: Error message
1:42:38 AM: Command failed with exit code 1: next build
1:42:38 AM: β
1:42:38 AM: Error location
1:42:38 AM: In Build command from Netlify app:
1:42:38 AM: next build
1:42:38 AM: β
1:42:38 AM: Resolved config
1:42:38 AM: build:
1:42:38 AM: command: next build
1:42:38 AM: commandOrigin: ui
1:42:38 AM: plugins:
1:42:38 AM: - inputs: {}
1:42:38 AM: origin: ui
1:42:38 AM: package: '@netlify/plugin-nextjs'
1:42:38 AM: Caching artifacts
1:42:38 AM: Started saving node modules
1:42:38 AM: Finished saving node modules
1:42:38 AM: Started saving build plugins
1:42:38 AM: Finished saving build plugins
1:42:38 AM: Started saving yarn cache
1:42:38 AM: Finished saving yarn cache
1:42:38 AM: Started saving pip cache
1:42:38 AM: Finished saving pip cache
1:42:38 AM: Started saving emacs cask dependencies
1:42:38 AM: Finished saving emacs cask dependencies
1:42:38 AM: Started saving maven dependencies
1:42:38 AM: Finished saving maven dependencies
1:42:38 AM: Started saving boot dependencies
1:42:38 AM: Finished saving boot dependencies
1:42:38 AM: Started saving rust rustup cache
1:42:38 AM: Finished saving rust rustup cache
1:42:39 AM: Started saving go dependencies
1:42:39 AM: Finished saving go dependencies
1:42:41 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:42:41 AM: Failing build: Failed to build site
1:42:41 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
1:42:41 AM: Finished processing build request in 1m29.215919022s
Somehow it is specific to Netlify, dont understand whyβ¦
package.json looks like that:
{
βnameβ: βnext-starterβ,
βversionβ: β0.1.0β,
βprivateβ: true,
βscriptsβ: {
βdevβ: βnext devβ,
βbuildβ: βnext buildβ,
βstartβ: βnext startβ,
βoutβ: βnext build && next exportβ
},
βdependenciesβ: {
β@material-ui/coreβ: β^4.11.3β,
βaxiosβ: β^0.21.1β,
βclsxβ: β^1.1.1β,
βgray-matterβ: β^4.0.2β,
βnextβ: βlatest@canaryβ,
βnext-mdx-remoteβ: β^2.1.3β,
βreactβ: β17.0.1β,
βreact-domβ: β17.0.1β,
βreact-iconsβ: β^4.2.0β,
βrssβ: β^1.2.2β,
βwebpackβ: β^5.23.0β
}
}
Hey perry, thanks for replying.
I managed to deal with above error, however still struggling with correct configuration to deploy next site to Netlifyβ¦
When following this guide
and settings in UI
βSet the build command to next build
Leave the publish directory blankβ
it does not work.
When I set publish directory to βout/β it builds fine but I cannot see changes pushed to GtiLab.
When I set build command to next build && next export which is yarn out in my config it works fineβ¦
However donβt understand why the guide is not telling about itβ¦ and what is the correct setup.
Hey @oskar1 , we are still discussing this and not 100% sure what to advise yet. Can you provide us with your netlify.toml file so we can take a closer look at some things?
I ran into the exact same error today when converting a very small project from .tsx to .jsx. Running the project through eslint and fixing the errors resolved the issue. Something to do with this in particular;
import React, { FunctionComponent, ReactElement } from 'react';
import { GetStaticProps, GetStaticPaths } from 'next';