Can't deploy next.js site

Hello, i am encountering a problem while trying to deploy my next.js app from this tutorial (https://www.youtube.com/watch?v=4mOkFXyxfsU). I think the problem might be that I have the wrong dependency’s installed but I don’t know how to fix it…

This is the deploy log:
11:25:50 AM: Build ready to start

11:25:52 AM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)

11:25:52 AM: build-image tag: v4.10.1

11:25:52 AM: buildbot version: 1c362ef848ac5e35535bdb572ebca893db28c8a0

11:25:52 AM: Fetching cached dependencies

11:25:52 AM: Failed to fetch cache, continuing with build

11:25:52 AM: Starting to prepare the repo for build

11:25:52 AM: No cached dependencies found. Cloning fresh repo

11:25:52 AM: git clone https://github.com/Thibaut738/RCD

11:25:57 AM: Preparing Git Reference refs/heads/main

11:25:57 AM: Parsing package.json dependencies

11:25:58 AM: Starting build script

11:25:58 AM: Installing dependencies

11:25:58 AM: Python version set to 2.7

11:25:59 AM: Downloading and installing node v16.17.1…

11:25:59 AM: Downloading https://nodejs.org/dist/v16.17.1/node-v16.17.1-linux-x64.tar.xz

11:25:59 AM: Computing checksum with sha256sum

11:25:59 AM: Checksums matched!

11:26:01 AM: Now using node v16.17.1 (npm v8.15.0)

11:26:01 AM: Started restoring cached build plugins

11:26:01 AM: Finished restoring cached build plugins

11:26:01 AM: Attempting ruby version 2.7.2, read from environment

11:26:02 AM: Using ruby version 2.7.2

11:26:02 AM: Using PHP version 8.0

11:26:02 AM: No npm workspaces detected

11:26:02 AM: Started restoring cached node modules

11:26:02 AM: Finished restoring cached node modules

11:26:02 AM: Installing NPM modules using NPM version 8.15.0

11:26:02 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special

11:26:02 AM: npm WARN config location in the cache, and they are managed by

11:26:02 AM: npm WARN config cacache.

11:26:03 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special

11:26:03 AM: npm WARN config location in the cache, and they are managed by

11:26:03 AM: npm WARN config cacache.

11:26:03 AM: npm ERR! code ERESOLVE

11:26:03 AM: npm ERR! ERESOLVE could not resolve

11:26:03 AM: npm ERR!

11:26:03 AM: npm ERR! While resolving: next-sanity-image@3.2.1

11:26:03 AM: npm ERR! Found: @sanity/client@3.4.1

11:26:03 AM: npm ERR! node_modules/@sanity/client

11:26:03 AM: npm ERR! @sanity/client@“^3.2.0” from the root project

11:26:03 AM: npm ERR!

11:26:03 AM: npm ERR! Could not resolve dependency:

11:26:03 AM: npm ERR! peer @sanity/client@“^2.11.0” from next-sanity-image@3.2.1

11:26:03 AM: npm ERR! node_modules/next-sanity-image

11:26:03 AM: npm ERR! next-sanity-image@“^3.2.1” from the root project

11:26:03 AM: npm ERR!

11:26:03 AM: npm ERR! Conflicting peer dependency: @sanity/client@2.23.2

11:26:03 AM: npm ERR! node_modules/@sanity/client

11:26:03 AM: npm ERR! peer @sanity/client@“^2.11.0” from next-sanity-image@3.2.1

11:26:03 AM: npm ERR! node_modules/next-sanity-image

11:26:03 AM: npm ERR! next-sanity-image@“^3.2.1” from the root project

11:26:03 AM: npm ERR!

11:26:03 AM: npm ERR! Fix the upstream dependency conflict, or retry

11:26:03 AM: npm ERR! this command with --force, or --legacy-peer-deps

11:26:03 AM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

11:26:03 AM: npm ERR!

11:26:03 AM: npm ERR! See /opt/buildhome/.npm/eresolve-report.txt for a full report.

11:26:03 AM: npm ERR! A complete log of this run can be found in:

11:26:03 AM: npm ERR! /opt/buildhome/.npm/_logs/2022-09-26T09_26_03_073Z-debug-0.log

11:26:03 AM: Error during NPM install

11:26:03 AM: Build was terminated: Build script returned non-zero exit code: 1

11:26:03 AM: Creating deploy upload records

11:26:04 AM: Failing build: Failed to build site

11:26:04 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1 (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)

11:26:04 AM: Finished processing build request in 11.871868119s

THIS IS THE

Hi @thibaut,

Thank you for reaching out and welcome to Netlify Support Forums.

I found a similar issue that was resolved here:

Could you let us know if this works for you?

Hi Melvin
First of all thank you so much for replying to my question, I really appreciate it.
I tried both --force and --legacy-peer-deps and it did seem to get further…
However I did encounter another problem.

This is the new build log:

10:53:06 AM: Build ready to start
10:53:17 AM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
10:53:17 AM: build-image tag: v4.10.1
10:53:17 AM: buildbot version: 1c362ef848ac5e35535bdb572ebca893db28c8a0
10:53:17 AM: Fetching cached dependencies
10:53:18 AM: Failed to fetch cache, continuing with build
10:53:18 AM: Starting to prepare the repo for build
10:53:18 AM: No cached dependencies found. Cloning fresh repo
10:53:18 AM: git clone https://github.com/Thibaut738/RCD
10:53:22 AM: Preparing Git Reference refs/heads/main
10:53:23 AM: Parsing package.json dependencies
10:53:24 AM: Starting build script
10:53:24 AM: Installing dependencies
10:53:24 AM: Python version set to 2.7
10:53:24 AM: Downloading and installing node v16.17.1…
10:53:24 AM: Downloading https://nodejs.org/dist/v16.17.1/node-v16.17.1-linux-x64.tar.xz
10:53:25 AM: Computing checksum with sha256sum
10:53:25 AM: Checksums matched!
10:53:27 AM: Now using node v16.17.1 (npm v8.15.0)
10:53:27 AM: Started restoring cached build plugins
10:53:27 AM: Finished restoring cached build plugins
10:53:27 AM: Attempting ruby version 2.7.2, read from environment
10:53:27 AM: Using ruby version 2.7.2
10:53:28 AM: Using PHP version 8.0
10:53:28 AM: No npm workspaces detected
10:53:28 AM: Started restoring cached node modules
10:53:28 AM: Finished restoring cached node modules
10:53:28 AM: Installing NPM modules using NPM version 8.15.0
10:53:28 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
10:53:28 AM: npm WARN config location in the cache, and they are managed by
10:53:28 AM: npm WARN config cacache.
10:53:29 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
10:53:29 AM: npm WARN config location in the cache, and they are managed by
10:53:29 AM: npm WARN config cacache.
10:53:35 AM: added 327 packages, and audited 328 packages in 6s
10:53:35 AM: 86 packages are looking for funding
10:53:35 AM: run npm fund for details
10:53:35 AM: found 0 vulnerabilities
10:53:35 AM: NPM modules installed
10:53:35 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
10:53:35 AM: npm WARN config location in the cache, and they are managed by
10:53:35 AM: npm WARN config cacache.
10:53:35 AM: Started restoring cached go cache
10:53:35 AM: Finished restoring cached go cache
10:53:35 AM: Installing Go version 1.17 (requested 1.17)
10:53:40 AM: unset GOOS;
10:53:40 AM: unset GOARCH;
10:53:40 AM: export GOROOT=‘/opt/buildhome/.gimme/versions/go1.17.linux.amd64’;
10:53:40 AM: export PATH=“/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}”;
10:53:40 AM: go version >&2;
10:53:40 AM: export GIMME_ENV=“/opt/buildhome/.gimme/env/go1.17.linux.amd64.env”
10:53:40 AM: go version go1.17 linux/amd64
10:53:40 AM: Installing missing commands
10:53:40 AM: Verify run directory
10:53:42 AM: ​
10:53:42 AM: ────────────────────────────────────────────────────────────────
10:53:42 AM: Netlify Build
10:53:42 AM: ────────────────────────────────────────────────────────────────
10:53:42 AM: ​
10:53:42 AM: ❯ Version
10:53:42 AM: @netlify/build 27.18.4
10:53:42 AM: ​
10:53:42 AM: ❯ Flags
10:53:42 AM: baseRelDir: true
10:53:42 AM: buildId: 63340b72521ff467977d9a30
10:53:42 AM: deployId: 63340b72521ff467977d9a32
10:53:42 AM: ​
10:53:42 AM: ❯ Current directory
10:53:42 AM: /opt/build/repo
10:53:42 AM: ​
10:53:42 AM: ❯ Config file
10:53:42 AM: No config file was defined: using default values.
10:53:42 AM: ​
10:53:42 AM: ❯ Context
10:53:42 AM: production
10:53:42 AM: ​
10:53:42 AM: ❯ Installing plugins
10:53:42 AM: - @netlify/plugin-nextjs@4.23.2
10:53:49 AM: ​
10:53:49 AM: ❯ Using Next.js Runtime - v4.23.2
10:53:50 AM: ​
10:53:50 AM: ────────────────────────────────────────────────────────────────
10:53:50 AM: 1. @netlify/plugin-nextjs (onPreBuild event)
10:53:50 AM: ────────────────────────────────────────────────────────────────
10:53:50 AM: ​
10:53:50 AM: No Next.js cache to restore.
10:53:50 AM: Netlify configuration property “build.environment.NEXT_PRIVATE_TARGET” value changed.
10:53:50 AM: ​
10:53:50 AM: (@netlify/plugin-nextjs onPreBuild completed in 14ms)
10:53:50 AM: ​
10:53:50 AM: ────────────────────────────────────────────────────────────────
10:53:50 AM: 2. Build command from Netlify app
10:53:50 AM: ────────────────────────────────────────────────────────────────
10:53:50 AM: ​
10:53:50 AM: $ npm run build
10:53:50 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
10:53:50 AM: npm WARN config location in the cache, and they are managed by
10:53:50 AM: npm WARN config cacache.
10:53:50 AM: > rcd_drone@0.1.0 build
10:53:50 AM: > next build
10:53:51 AM: info - Loaded env from /opt/build/repo/.env
10:53:51 AM: warn - SWC minify release candidate enabled. swc-minify-enabled | Next.js
10:53:51 AM: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: no-cache | Next.js
10:53:51 AM: info - Checking validity of types…
10:53:52 AM: ./pages/product/[slug].js
10:53:52 AM: 24:13 Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images. jsx-a11y/alt-text
10:53:52 AM: 24:13 Warning: Do not use <img> element. Use <Image /> from next/image instead. See: no-img-element | Next.js @next/next/no-img-element
10:53:52 AM: 28:15 Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images. jsx-a11y/alt-text
10:53:52 AM: 28:15 Warning: Do not use <img> element. Use <Image /> from next/image instead. See: no-img-element | Next.js @next/next/no-img-element
10:53:52 AM: ./pages/success.js
10:53:52 AM: 17:6 Warning: React Hook useEffect has missing dependencies: ‘setCartItems’, ‘setTotalPrice’, and ‘setTotalQuantities’. Either include them or remove the dependency array. react-hooks/exhaustive-deps
10:53:52 AM: ./components/Cart.jsx
10:53:52 AM: 66:15 Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images. jsx-a11y/alt-text
10:53:52 AM: 66:15 Warning: Do not use <img> element. Use <Image /> from next/image instead. See: no-img-element | Next.js @next/next/no-img-element
10:53:52 AM: ./components/FooterBanner.jsx
10:53:52 AM: 25:9 Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images. jsx-a11y/alt-text
10:53:52 AM: 25:9 Warning: Do not use <img> element. Use <Image /> from next/image instead. See: no-img-element | Next.js @next/next/no-img-element
10:53:52 AM: ./components/HeroBanner.jsx
10:53:52 AM: 13:9 Warning: Do not use <img> element. Use <Image /> from next/image instead. See: no-img-element | Next.js @next/next/no-img-element
10:53:52 AM: ./components/Product.jsx
10:53:52 AM: 11:11 Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images. jsx-a11y/alt-text
10:53:52 AM: 11:11 Warning: Do not use <img> element. Use <Image /> from next/image instead. See: no-img-element | Next.js @next/next/no-img-element
10:53:52 AM: info - Need to disable some ESLint rules? Learn more here: Basic Features: ESLint | Next.js
10:53:52 AM: info - Creating an optimized production build…
10:53:52 AM: info - Disabled SWC as replacement for Babel because of custom Babel configuration “.babelrc” swc-disabled | Next.js
10:53:53 AM: info - Using external babel configuration from /opt/build/repo/.babelrc
10:53:57 AM: Failed to compile.
10:53:57 AM:
10:53:57 AM: ./components/Cart.jsx
10:53:57 AM: Module not found: Can’t resolve ‘…/lib/client’ in ‘/opt/build/repo/components’
10:53:57 AM: Import trace for requested module:
10:53:57 AM: ./components/index.js
10:53:57 AM: ./pages/_app.js
10:53:57 AM: ./components/Cart.jsx
10:53:57 AM: Module not found: Can’t resolve ‘…/lib/getStripe’ in ‘/opt/build/repo/components’
10:53:57 AM: Import trace for requested module:
10:53:57 AM: ./components/index.js
10:53:57 AM: ./pages/_app.js
10:53:57 AM: ./components/FooterBanner.jsx
10:53:57 AM: Module not found: Can’t resolve ‘…/lib/client’ in ‘/opt/build/repo/components’
10:53:57 AM: Import trace for requested module:
10:53:57 AM: ./components/index.js
10:53:57 AM: ./pages/_app.js
10:53:57 AM: ./components/HeroBanner.jsx
10:53:57 AM: Module not found: Can’t resolve ‘…/lib/client’ in ‘/opt/build/repo/components’
10:53:57 AM: Import trace for requested module:
10:53:57 AM: ./components/index.js
10:53:57 AM: ./pages/_app.js
10:53:57 AM: ./components/Product.jsx
10:53:57 AM: Module not found: Can’t resolve ‘…/lib/client’ in ‘/opt/build/repo/components’
10:53:57 AM: Import trace for requested module:
10:53:57 AM: ./components/index.js
10:53:57 AM: ./pages/_app.js
10:53:57 AM: > Build failed because of webpack errors
10:53:57 AM: ​
10:53:57 AM: ────────────────────────────────────────────────────────────────
10:53:57 AM: “build.command” failed
10:53:57 AM: ────────────────────────────────────────────────────────────────
10:53:57 AM: ​
10:53:57 AM: Error message
10:53:58 AM: Creating deploy upload records
10:53:57 AM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
10:53:57 AM: ​
10:53:57 AM: Error location
10:53:57 AM: In Build command from Netlify app:
10:53:57 AM: npm run build
10:53:58 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)
10:53:57 AM: ​
10:53:57 AM: Resolved config
10:53:57 AM: build:
10:53:57 AM: command: npm run build
10:53:57 AM: commandOrigin: ui
10:53:57 AM: environment:
10:53:57 AM: - NPM_FLAGS
10:53:57 AM: - NEXT_PRIVATE_TARGET
10:53:57 AM: publish: /opt/build/repo/.next
10:53:57 AM: publishOrigin: ui
10:53:57 AM: plugins:
10:53:57 AM: - inputs: {}
10:53:57 AM: origin: ui
10:53:57 AM: package: ‘@netlify/plugin-nextjs’
10:53:57 AM: Caching artifacts
10:53:57 AM: Started saving node modules
10:53:57 AM: Finished saving node modules
10:53:57 AM: Started saving build plugins
10:53:57 AM: Finished saving build plugins
10:53:57 AM: Started saving pip cache
10:53:57 AM: Finished saving pip cache
10:53:57 AM: Started saving emacs cask dependencies
10:53:57 AM: Finished saving emacs cask dependencies
10:53:57 AM: Started saving maven dependencies
10:53:57 AM: Finished saving maven dependencies
10:53:57 AM: Started saving boot dependencies
10:53:57 AM: Finished saving boot dependencies
10:53:57 AM: Started saving rust rustup cache
10:53:57 AM: Finished saving rust rustup cache
10:53:57 AM: Started saving go dependencies
10:53:57 AM: Finished saving go dependencies
10:53:58 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:53:58 AM: Failing build: Failed to build site
10:53:58 AM: Finished processing build request in 40.744038803s

Hi @thibaut,

Thanks for the follow-up and letting us know you’re still having issues.

From the new log, I do see multiple Module not found: Can’t resolve messages.

Can you let us know if you’re able to build locally?

We have a Support Guide here if you’re able to build locally but builds fail on deploy. This could be caused by case sensitivity. This Netlify Support Forum of a similar issue here which was an issue with case sensitivity.

Let us know if you have any questions.

Hi Melvin

Sorry for my late response… I was able to build locally.
I also looked at the suggestion you made that it mayby was case sensitivity. I found out I didn’t have the right variables in my envirement variables. I also tried the commands : " git config --global core.ignorecase false " and " git config --local core.ignorecase false "

However I do still get the same kind of error.

thanks in advance!

The new deploy log:
8:28:57 AM: Build ready to start
8:28:58 AM: build-image version: 9289b698a503f132b265bd089ab40ce1d6f9e65e (focal)
8:28:58 AM: build-image tag: v4.12.0
8:28:58 AM: buildbot version: 8004afba0d79c2913deefb1ea0ee8f3ed710b828
8:28:58 AM: Building without cache
8:28:58 AM: Starting to prepare the repo for build
8:28:58 AM: No cached dependencies found. Cloning fresh repo
8:28:58 AM: git clone https://github.com/Thibaut738/RCD
8:29:02 AM: Preparing Git Reference refs/heads/main
8:29:04 AM: Parsing package.json dependencies
8:29:05 AM: Starting build script
8:29:05 AM: Installing dependencies
8:29:05 AM: Python version set to 2.7
8:29:05 AM: v16.17.1 is already installed.
8:29:06 AM: Now using node v16.17.1 (npm v8.15.0)
8:29:06 AM: Started restoring cached build plugins
8:29:06 AM: Finished restoring cached build plugins
8:29:06 AM: Attempting ruby version 2.7.2, read from environment
8:29:06 AM: Using ruby version 2.7.2
8:29:07 AM: Using PHP version 8.0
8:29:07 AM: No npm workspaces detected
8:29:07 AM: Started restoring cached node modules
8:29:07 AM: Finished restoring cached node modules
8:29:07 AM: Installing NPM modules using NPM version 8.15.0
8:29:07 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
8:29:07 AM: npm WARN config location in the cache, and they are managed by
8:29:07 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
8:29:08 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
8:29:08 AM: npm WARN config location in the cache, and they are managed by
8:29:08 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
8:29:13 AM: added 343 packages, and audited 344 packages in 6s
8:29:13 AM: 80 packages are looking for funding
8:29:13 AM:   run `npm fund` for details
8:29:13 AM: found 0 vulnerabilities
8:29:13 AM: NPM modules installed
8:29:13 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
8:29:13 AM: npm WARN config location in the cache, and they are managed by
8:29:13 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
8:29:13 AM: Started restoring cached go cache
8:29:13 AM: Finished restoring cached go cache
8:29:13 AM: Installing Go version 1.17 (requested 1.17)
8:29:19 AM: unset GOOS;
8:29:19 AM: unset GOARCH;
8:29:19 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
8:29:19 AM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
8:29:19 AM: go version >&2;
8:29:19 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
8:29:19 AM: go version go1.17 linux/amd64
8:29:19 AM: Installing missing commands
8:29:19 AM: Verify run directory
8:29:20 AM: ​
8:29:20 AM: ────────────────────────────────────────────────────────────────
8:29:20 AM:   Netlify Build                                                 
8:29:20 AM: ────────────────────────────────────────────────────────────────
8:29:20 AM: ​
8:29:20 AM: ❯ Version
8:29:20 AM:   @netlify/build 27.20.1
8:29:20 AM: ​
8:29:20 AM: ❯ Flags
8:29:20 AM:   baseRelDir: true
8:29:20 AM:   buildId: 633bd2a9f6573335f5a243d7
8:29:20 AM:   deployId: 633bd2a9f6573335f5a243d9
8:29:20 AM: ​
8:29:20 AM: ❯ Current directory
8:29:20 AM:   /opt/build/repo
8:29:20 AM: ​
8:29:20 AM: ❯ Config file
8:29:20 AM:   No config file was defined: using default values.
8:29:20 AM: ​
8:29:20 AM: ❯ Context
8:29:20 AM:   production
8:29:20 AM: ​
8:29:20 AM: ❯ Installing plugins
8:29:20 AM:    - @netlify/plugin-nextjs@4.23.3
8:29:28 AM: ​
8:29:28 AM: ❯ Using Next.js Runtime - v4.23.3
8:29:29 AM: ​
8:29:29 AM: ────────────────────────────────────────────────────────────────
8:29:29 AM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
8:29:29 AM: ────────────────────────────────────────────────────────────────
8:29:29 AM: ​
8:29:29 AM: No Next.js cache to restore.
8:29:29 AM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
8:29:29 AM: ​
8:29:29 AM: (@netlify/plugin-nextjs onPreBuild completed in 16ms)
8:29:29 AM: ​
8:29:29 AM: ────────────────────────────────────────────────────────────────
8:29:29 AM:   2. Build command from Netlify app                             
8:29:29 AM: ────────────────────────────────────────────────────────────────
8:29:29 AM: ​
8:29:29 AM: $ npm run build
8:29:29 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
8:29:29 AM: npm WARN config location in the cache, and they are managed by
8:29:29 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
8:29:29 AM: > rcd_drone@0.1.0 build
8:29:29 AM: > next build
8:29:29 AM: info  - Loaded env from /opt/build/repo/.env
8:29:29 AM: warn  - SWC minify release candidate enabled. https://nextjs.org/docs/messages/swc-minify-enabled
8:29:29 AM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
8:29:30 AM: info  - Checking validity of types...
8:29:31 AM: ./pages/product/[slug].js
8:29:31 AM: 24:13  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text
8:29:31 AM: 24:13  Warning: Do not use <img>. Use Image from 'next/image' instead. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
8:29:31 AM: 28:15  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text
8:29:31 AM: 28:15  Warning: Do not use <img>. Use Image from 'next/image' instead. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
8:29:31 AM: ./pages/success.js
8:29:31 AM: 17:6  Warning: React Hook useEffect has missing dependencies: 'setCartItems', 'setTotalPrice', and 'setTotalQuantities'. Either include them or remove the dependency array.  react-hooks/exhaustive-deps
8:29:31 AM: 33:9  Warning: passHref is missing. See: https://nextjs.org/docs/messages/link-passhref  @next/next/link-passhref
8:29:31 AM: ./components/Cart.jsx
8:29:31 AM: 51:13  Warning: passHref is missing. See: https://nextjs.org/docs/messages/link-passhref  @next/next/link-passhref
8:29:31 AM: 66:15  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text
8:29:31 AM: 66:15  Warning: Do not use <img>. Use Image from 'next/image' instead. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
8:29:31 AM: ./components/FooterBanner.jsx
8:29:31 AM: 20:11  Warning: passHref is missing. See: https://nextjs.org/docs/messages/link-passhref  @next/next/link-passhref
8:29:31 AM: 25:9  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text
8:29:31 AM: 25:9  Warning: Do not use <img>. Use Image from 'next/image' instead. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
8:29:31 AM: ./components/HeroBanner.jsx
8:29:31 AM: 13:9  Warning: Do not use <img>. Use Image from 'next/image' instead. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
8:29:31 AM: 16:11  Warning: passHref is missing. See: https://nextjs.org/docs/messages/link-passhref  @next/next/link-passhref
8:29:31 AM: ./components/Product.jsx
8:29:31 AM: 9:7  Warning: passHref is missing. See: https://nextjs.org/docs/messages/link-passhref  @next/next/link-passhref
8:29:31 AM: 11:11  Warning: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images.  jsx-a11y/alt-text
8:29:31 AM: 11:11  Warning: Do not use <img>. Use Image from 'next/image' instead. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
8:29:31 AM: info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
8:29:31 AM: info  - Creating an optimized production build...
8:29:31 AM: info  - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
8:29:32 AM: info  - Using external babel configuration from /opt/build/repo/.babelrc
8:29:35 AM: Failed to compile.
8:29:35 AM: 
8:29:35 AM: ./components/Cart.jsx
8:29:35 AM: Module not found: Can't resolve '../lib/client' in '/opt/build/repo/components'
8:29:35 AM: Import trace for requested module:
8:29:35 AM: ./components/index.js
8:29:35 AM: ./pages/_app.js
8:29:35 AM: ./components/Cart.jsx
8:29:35 AM: Module not found: Can't resolve '../lib/getStripe' in '/opt/build/repo/components'
8:29:35 AM: Import trace for requested module:
8:29:35 AM: ./components/index.js
8:29:35 AM: ./pages/_app.js
8:29:35 AM: ./components/FooterBanner.jsx
8:29:35 AM: Module not found: Can't resolve '../lib/client' in '/opt/build/repo/components'
8:29:35 AM: Import trace for requested module:
8:29:35 AM: ./components/index.js
8:29:35 AM: ./pages/_app.js
8:29:35 AM: ./components/HeroBanner.jsx
8:29:35 AM: Module not found: Can't resolve '../lib/client' in '/opt/build/repo/components'
8:29:35 AM: Import trace for requested module:
8:29:35 AM: ./components/index.js
8:29:35 AM: ./pages/_app.js
8:29:35 AM: ./components/Product.jsx
8:29:35 AM: Module not found: Can't resolve '../lib/client' in '/opt/build/repo/components'
8:29:35 AM: Import trace for requested module:
8:29:35 AM: ./components/index.js
8:29:35 AM: ./pages/_app.js
8:29:35 AM: > Build failed because of webpack errors
8:29:35 AM: ​
8:29:35 AM: ────────────────────────────────────────────────────────────────
8:29:35 AM:   "build.command" failed                                        
8:29:35 AM: ────────────────────────────────────────────────────────────────
8:29:35 AM: ​
8:29:35 AM:   Error message
8:29:35 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
8:29:35 AM: ​
8:29:35 AM:   Error location
8:29:35 AM:   In Build command from Netlify app:
8:29:35 AM:   npm run build
8:29:35 AM: ​
8:29:35 AM:   Resolved config
8:29:35 AM:   build:
8:29:35 AM:     command: npm run build
8:29:35 AM:     commandOrigin: ui
8:29:35 AM:     environment:
8:29:35 AM:       - NEXT_PUBLIC_SANITY_TOKEN
8:29:35 AM:       - NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
8:29:35 AM:       - NEXT_PUBLIC_STRIPE_SECRET_KEY
8:29:35 AM:       - NPM_FLAGS
8:29:35 AM:       - NEXT_PRIVATE_TARGET
8:29:35 AM:     publish: /opt/build/repo/.next
8:29:35 AM:     publishOrigin: ui
8:29:35 AM:   plugins:
8:29:35 AM:     - inputs: {}
8:29:35 AM:       origin: ui
8:29:35 AM:       package: '@netlify/plugin-nextjs'
8:29:35 AM: Caching artifacts
8:29:35 AM: Started saving node modules
8:29:35 AM: Finished saving node modules
8:29:35 AM: Started saving build plugins
8:29:35 AM: Finished saving build plugins
8:29:35 AM: Started saving pip cache
8:29:35 AM: Finished saving pip cache
8:29:35 AM: Started saving emacs cask dependencies
8:29:35 AM: Finished saving emacs cask dependencies
8:29:35 AM: Started saving maven dependencies
8:29:35 AM: Finished saving maven dependencies
8:29:35 AM: Started saving boot dependencies
8:29:35 AM: Finished saving boot dependencies
8:29:35 AM: Started saving rust rustup cache
8:29:35 AM: Finished saving rust rustup cache
8:29:35 AM: Started saving go dependencies
8:29:35 AM: Finished saving go dependencies
8:29:36 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:29:36 AM: Creating deploy upload records
8:29:36 AM: Failing build: Failed to build site
8:29:36 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
8:29:37 AM: Finished processing build request in 38.508969305s

From the error message:

Module not found: Can't resolve '../lib/client' in '/opt/build/repo/components'

Either the module isn’t in your repo or the filename is different than the one used in import statement.

This support guide mentions issues that can be faced due to mixed case filenames. Could you double check the filenames to ensure they are there and correct?

Hi Melvin

Your suggestion was correct. There was a problem with case sensitivity in my folders.
Thanks you so much for all the help, I really appreciate it! :slight_smile: