Skip to content

Building failing with Next Project - next.config.js and netlify.toml #377

Closed
@tgmarinho

Description

@tgmarinho

Describe the bug
I am folling this steps: https://github.com/netlify/netlify-plugin-nextjs and

Build process is failing,

Netlify UI there is not set up to deploy, but there is a plugin: Essential Next.js

When I try to do local build it fails also, because of config below:

Look at my settings:

next.config.js:

const withAntdLess = require("next-plugin-antd-less");
const libtheme = require("./libtheme");
const withPlugins = require("next-compose-plugins");

module.exports = withPlugins(
	[
		[
			withAntdLess,
			{
				modifyVars: libtheme,
			},
		],
	],
	{
		target: "serverless",
		reactStrictMode: true,
		poweredByHeader: false,
		images: {
			deviceSizes: [300, 640, 750, 828, 1080, 1200, 1920, 2048, 3840],
			imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
			domains: [
				"localhost",
				"gateway.pinata.cloud",
				"cloudfront.net",
				"rplanet.io",
				"static.tribalbooks.io",
			],
		},
	},
);

netlify.toml:

[build]
  command = "npm run build"
  publish = "out"

[[plugins]]
  package = "@netlify/plugin-nextjs"

[context.production.environment]
NEXT_SERVERLESS = "true"
NODE_ENV = "production"

Versions

  • "next": "^10.0.9",
  • plugin (if installed at fixed version): "@netlify/plugin-nextjs": "^3.3.1",

Log Error when building:

11:57:49 AM: Build ready to start
11:57:51 AM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
11:57:51 AM: build-image tag: v3.7.6
11:57:51 AM: buildbot version: 1d23d79c8af5b62cf7a13e959844b03de737277f
11:57:51 AM: Building without cache
11:57:51 AM: Starting to prepare the repo for build
11:57:53 AM: No cached dependencies found. Cloning fresh repo
11:57:53 AM: git clone https://github.com/popstand/wax-nft-marketplace
11:57:54 AM: Preparing Git Reference pull/59/head
11:57:54 AM: Parsing package.json dependencies
11:57:55 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'out' versus '' in the Netlify UI
11:57:55 AM: Different build command detected, going to use the one specified in the Netlify configuration file: 'npm run build' versus '' in the Netlify UI
11:57:55 AM: Starting build script
11:57:55 AM: Installing dependencies
11:57:55 AM: Python version set to 2.7
11:57:56 AM: v12.18.0 is already installed.
11:57:57 AM: Now using node v12.18.0 (npm v6.14.4)
11:57:57 AM: Started restoring cached build plugins
11:57:57 AM: Finished restoring cached build plugins
11:57:57 AM: Attempting ruby version 2.7.1, read from environment
11:57:58 AM: Using ruby version 2.7.1
11:57:59 AM: Using PHP version 5.6
11:57:59 AM: Started restoring cached yarn cache
11:57:59 AM: Finished restoring cached yarn cache
11:57:59 AM: Installing yarn at version 1.22.4
11:57:59 AM: Installing Yarn!
11:57:59 AM: > Downloading tarball...
11:57:59 AM: [1/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz --> /tmp/yarn.tar.gz.3AIQljOPZp
11:57:59 AM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
11:57:59 AM:                                  Dload  Upload   Total   Spent    Left  Speed
11:57:59 AM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
11:57:59 AM: 100    79  100    79    0     0    327      0 --:--:-- --:--:-- --:--:--   327
11:57:59 AM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
11:57:59 AM: 100    93  100    93    0     0    154      0 --:--:-- --:--:-- --:--:--   948
11:58:00 AM: 100   625  100   625    0     0    729      0 --:--:-- --:--:-- --:--:--   729
11:58:00 AM: 100 1215k  100 1215k    0     0  1037k      0  0:00:01  0:00:01 --:--:-- 1037k
11:58:00 AM: [2/2]: https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz.asc --> /tmp/yarn.tar.gz.3AIQljOPZp.asc
11:58:00 AM: 100    83  100    83    0     0   1049      0 --:--:-- --:--:-- --:--:--  1049
11:58:00 AM: 100    97  100    97    0     0    892      0 --:--:-- --:--:-- --:--:--   892
11:58:00 AM: 100   629  100   629    0     0   4623      0 --:--:-- --:--:-- --:--:--  4623
11:58:00 AM: 100  1028  100  1028    0     0   6293      0 --:--:-- --:--:-- --:--:--  6293
11:58:00 AM: > Verifying integrity...
11:58:00 AM: gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC using RSA key ID 69475BAA
11:58:00 AM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
11:58:00 AM: gpg: WARNING: This key is not certified with a trusted signature!
11:58:00 AM: gpg:          There is no indication that the signature belongs to the owner.
11:58:00 AM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
11:58:00 AM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
11:58:00 AM: > GPG signature looks good
11:58:00 AM: > Extracting to ~/.yarn...
11:58:00 AM: > Adding to $PATH...
11:58:01 AM: > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
11:58:01 AM: No yarn workspaces detected
11:58:01 AM: Started restoring cached node modules
11:58:01 AM: Finished restoring cached node modules
11:58:01 AM: Installing NPM modules using Yarn version 1.22.4
11:58:02 AM: yarn install v1.22.4
11:58:02 AM: [1/4] Resolving packages...
11:58:02 AM: [2/4] Fetching packages...
11:58:28 AM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
11:58:28 AM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
11:58:28 AM: [3/4] Linking dependencies...
11:58:28 AM: warning "@netlify/plugin-nextjs > @sls-next/lambda-at-edge > @vercel/nft > acorn-export-ns-from@0.1.0" has incorrect peer dependency "acorn@^6.0.1".
11:58:28 AM: warning "@netlify/plugin-nextjs > @sls-next/lambda-at-edge > @aws-sdk/client-s3 > @aws-sdk/middleware-retry > react-native-get-random-values@1.7.0" has unmet peer dependency "react-native@>=0.56".
11:58:28 AM: warning "antd > rc-picker@2.5.10" has unmet peer dependency "dayjs@^1.8.30".
11:58:28 AM: warning "next-plugin-antd-less > less-loader@7.3.0" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
11:58:28 AM: warning "next-plugin-antd-less > null-loader@4.0.1" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
11:58:28 AM: warning "react-image-gallery > react-swipeable@5.5.1" has incorrect peer dependency "react@^16.0.0-0".
11:58:28 AM: warning " > react-select-search@3.0.7" has unmet peer dependency "prop-types@^15.7.2".
11:58:28 AM: warning " > styled-components@5.3.0" has unmet peer dependency "react-is@>= 16.8.0".
11:58:43 AM: [4/4] Building fresh packages...
11:58:46 AM: $ husky install
11:58:46 AM: husky - Git hooks installed
11:58:46 AM: Done in 44.89s.
11:58:47 AM: NPM modules installed using Yarn
11:58:47 AM: Started restoring cached go cache
11:58:47 AM: Finished restoring cached go cache
11:58:47 AM: go version go1.14.4 linux/amd64
11:58:47 AM: go version go1.14.4 linux/amd64
11:58:47 AM: Installing missing commands
11:58:47 AM: Verify run directory
11:58:48 AM: ​
11:58:48 AM: ────────────────────────────────────────────────────────────────
11:58:48 AM:   Netlify Build                                                 
11:58:48 AM: ────────────────────────────────────────────────────────────────
11:58:48 AM: ​
11:58:48 AM: ❯ Version
11:58:48 AM:   @netlify/build 11.29.2
11:58:48 AM: ​
11:58:48 AM: ❯ Flags
11:58:48 AM:   deployId: 60b7aa7de964ca5fa1596c93
11:58:48 AM: ​
11:58:48 AM: ❯ Current directory
11:58:48 AM:   /opt/build/repo
11:58:48 AM: ​
11:58:48 AM: ❯ Config file
11:58:48 AM:   /opt/build/repo/netlify.toml
11:58:48 AM: ​
11:58:48 AM: ❯ Context
11:58:48 AM:   deploy-preview
11:58:48 AM: ​
11:58:48 AM: ❯ Loading plugins
11:58:48 AM:    - @netlify/plugin-nextjs@3.3.1 from netlify.toml and package.json
11:58:48 AM: ​
11:58:48 AM: ────────────────────────────────────────────────────────────────
11:58:48 AM:   1. onPreBuild command from @netlify/plugin-nextjs             
11:58:48 AM: ────────────────────────────────────────────────────────────────
11:58:48 AM: ​
11:58:49 AM: info  - Using webpack 4. Reason: future.webpack5 option disabled https://nextjs.org/docs/messages/webpack5
11:58:49 AM: Image domains set in next.config.js are ignored.
11:58:49 AM: Please set the env variable NEXT_IMAGE_ALLOWED_DOMAINS to "localhost,gateway.pinata.cloud,cloudfront.net,rplanet.io,static.tribalbooks.io" instead
11:58:49 AM: No Next.js cache to restore.
11:58:49 AM: ​
11:58:49 AM: (@netlify/plugin-nextjs onPreBuild completed in 948ms)
11:58:49 AM: ​
11:58:49 AM: ────────────────────────────────────────────────────────────────
11:58:49 AM:   2. build.command from netlify.toml                            
11:58:49 AM: ────────────────────────────────────────────────────────────────
11:58:49 AM: ​
11:58:49 AM: $ npm run build
11:58:49 AM: > wax-nft-marketplace@1.0.0 build /opt/build/repo
11:58:49 AM: > next build
11:58:50 AM: info  - Using webpack 4. Reason: future.webpack5 option disabled https://nextjs.org/docs/messages/webpack5
11:58:50 AM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
11:58:50 AM: info  - Checking validity of types...
11:59:02 AM: info  - Creating an optimized production build...
11:59:03 AM: info  - Using external babel configuration from /opt/build/repo/.babelrc.js
12:00:43 PM: warn  - Compiled with warnings
12:00:43 PM: ./node_modules/next/dist/next-server/server/load-components.js
12:00:43 PM: Critical dependency: the request of a dependency is an expression
12:00:43 PM: ./node_modules/next/dist/next-server/server/load-components.js
12:00:43 PM: Critical dependency: the request of a dependency is an expression
12:00:43 PM: ./node_modules/next/dist/next-server/server/load-components.js
12:00:43 PM: Critical dependency: the request of a dependency is an expression
12:00:43 PM: ./node_modules/next/dist/next-server/server/require.js
12:00:43 PM: Critical dependency: the request of a dependency is an expression
12:00:43 PM: ./node_modules/next/dist/next-server/server/require.js
12:00:43 PM: Critical dependency: the request of a dependency is an expression
12:00:43 PM: ./node_modules/next/dist/next-server/server/require.js
12:00:43 PM: Critical dependency: the request of a dependency is an expression
12:00:43 PM: ./node_modules/isomorphic-ws/node_modules/ws/lib/buffer-util.js
12:00:43 PM: Module not found: Can't resolve 'bufferutil' in '/opt/build/repo/node_modules/isomorphic-ws/node_modules/ws/lib'
12:00:43 PM: ./node_modules/isomorphic-ws/node_modules/ws/lib/validation.js
12:00:43 PM: Module not found: Can't resolve 'utf-8-validate' in '/opt/build/repo/node_modules/isomorphic-ws/node_modules/ws/lib'
12:00:43 PM: info  - Collecting page data...
12:00:45 PM: > Build error occurred
12:00:45 PM: TypeError: (0 , _styleChecker.isStyleSupport) is not a function
12:00:45 PM:     at Object.g5iu (/opt/build/repo/.next/serverless/pages/_error.js:138873:59)
12:00:45 PM:     at __webpack_require__ (/opt/build/repo/.next/serverless/pages/_error.js:23:31)
12:00:45 PM:     at Object.3PeW (/opt/build/repo/.next/serverless/pages/_error.js:11714:36)
12:00:45 PM:     at __webpack_require__ (/opt/build/repo/.next/serverless/pages/_error.js:23:31)
12:00:45 PM:     at Object.lbd2 (/opt/build/repo/.next/serverless/pages/_error.js:160882:36)
12:00:45 PM:     at __webpack_require__ (/opt/build/repo/.next/serverless/pages/_error.js:23:31)
12:00:45 PM:     at Module.hUgY (/opt/build/repo/.next/serverless/pages/_error.js:144632:18)
12:00:45 PM:     at __webpack_require__ (/opt/build/repo/.next/serverless/pages/_error.js:23:31)
12:00:45 PM:     at Module.M7T7 (/opt/build/repo/.next/serverless/pages/_error.js:70492:22)
12:00:45 PM:     at __webpack_require__ (/opt/build/repo/.next/serverless/pages/_error.js:23:31)
12:00:45 PM:     at /opt/build/repo/.next/serverless/pages/_error.js:95:18
12:00:45 PM:     at Object.<anonymous> (/opt/build/repo/.next/serverless/pages/_error.js:98:10)
12:00:45 PM:     at Module._compile (internal/modules/cjs/loader.js:1138:30)
12:00:45 PM:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
12:00:45 PM:     at Module.load (internal/modules/cjs/loader.js:986:32)
12:00:45 PM:     at Function.Module._load (internal/modules/cjs/loader.js:879:14)
12:00:45 PM: npm ERR! code ELIFECYCLE
12:00:45 PM: npm ERR! errno 1
12:00:45 PM: npm ERR! wax-nft-marketplace@1.0.0 build: `next build`
12:00:45 PM: npm ERR! Exit status 1
12:00:45 PM: npm ERR!
12:00:45 PM: npm ERR! Failed at the wax-nft-marketplace@1.0.0 build script.
12:00:45 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:00:45 PM: npm ERR! A complete log of this run can be found in:
12:00:45 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-06-02T16_00_45_220Z-debug.log
12:00:45 PM: ​
12:00:45 PM: ────────────────────────────────────────────────────────────────
12:00:45 PM:   "build.command" failed                                        
12:00:45 PM: ────────────────────────────────────────────────────────────────
12:00:45 PM: ​
12:00:45 PM:   Error message
12:00:45 PM:   Command failed with exit code 1: npm run build
12:00:45 PM: ​
12:00:45 PM:   Error location
12:00:45 PM:   In build.command from netlify.toml:
12:00:45 PM:   npm run build
12:00:45 PM: ​
12:00:45 PM:   Resolved config
12:00:45 PM:   build:
12:00:45 PM:     command: npm run build
12:00:45 PM:     commandOrigin: config
12:00:45 PM:     environment:
12:00:45 PM:       - NEXT_PUBLIC_EXPLORER_API_ENDPOINT
12:00:45 PM:       - NEXT_PUBLIC_IPFS_ENDPOINT
12:00:45 PM:       - NEXT_PUBLIC_MARKETPLACE_COLLECTION_FEE
12:00:45 PM:       - NEXT_PUBLIC_NAME
12:00:45 PM:       - NEXT_PUBLIC_PINATA_API_ENDPOINT
12:00:45 PM:       - NEXT_PUBLIC_PINATA_API_KEY
12:00:45 PM:       - NEXT_PUBLIC_PINATA_SECRET
12:00:45 PM:       - NEXT_PUBLIC_UAL_CHAIN_HOST
12:00:45 PM:       - NEXT_PUBLIC_UAL_CHAIN_ID
12:00:45 PM:       - NEXT_PUBLIC_UAL_CHAIN_PORT
12:00:45 PM:       - NEXT_PUBLIC_UAL_CHAIN_PROTOCOL
12:00:45 PM:       - REVIEW_ID
12:00:45 PM:     publish: /opt/build/repo/out
12:00:45 PM:   functions:
12:00:45 PM:     '*': {}
12:00:45 PM:   plugins:
12:00:45 PM:     - inputs: {}
12:00:45 PM:       origin: config
12:00:45 PM:       package: '@netlify/plugin-nextjs'
12:00:45 PM: Caching artifacts
12:00:45 PM: Started saving node modules
12:00:45 PM: Finished saving node modules
12:00:45 PM: Started saving build plugins
12:00:45 PM: Finished saving build plugins
12:00:45 PM: Started saving yarn cache
12:00:45 PM: Finished saving yarn cache
12:00:45 PM: Started saving pip cache
12:00:45 PM: Finished saving pip cache
12:00:45 PM: Started saving emacs cask dependencies
12:00:45 PM: Finished saving emacs cask dependencies
12:00:45 PM: Started saving maven dependencies
12:00:45 PM: Finished saving maven dependencies
12:00:45 PM: Started saving boot dependencies
12:00:45 PM: Finished saving boot dependencies
12:00:45 PM: Started saving rust rustup cache
12:00:45 PM: Finished saving rust rustup cache
12:00:45 PM: Started saving go dependencies
12:00:45 PM: Finished saving go dependencies
12:00:48 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:00:48 PM: Creating deploy upload records
12:00:48 PM: Failing build: Failed to build site
12:00:48 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
12:00:48 PM: Finished processing build request in 2m56.851236198s

Maybe is missing in the documentation about:

11:58:49 AM: Please set the env variable NEXT_IMAGE_ALLOWED_DOMAINS to "localhost,gateway.pinata.cloud,cloudfront.net,rplanet.io,static.tribalbooks.io" instead

It is in the next.config.js

Error:

12:00:43 PM: info  - Collecting page data...
12:00:45 PM: > Build error occurred
12:00:45 PM: TypeError: (0 , _styleChecker.isStyleSupport) is not a function
12:00:45 PM:     at Object.g5iu (/opt/build/repo/.next/serverless/pages/_error.js:138873:59)

there is the folder: serverless that appear when a set target: "serverless" in next.config.js.

What am I missing?

When I try to build without target: "serverless", build pass, but I get 404 page not found, it seems that the static files are not loaded to "out" folder.

I'm using SSR and SSG data fetching.

Structure folder of project:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions