Build.command failed error exit code 1 and 2, module not found

I have trouble deploying my nextjs project.
Some .scss imports in the _app.tsx file presented ‘module not found error’
Build command failed.
Error exit code 1 and 2 are shown.

I have already tried the command npm run build in my machine and it do not presented any error.
The last thing I’ve done to try solve this problem was updating local packages with npm update command and it is still not working.

GitHub repo: GitHub - HigorR456/poke-store: This is a Pokemon Store personal project, made with ReactJS, Redux and Next.js. The purpose of this project is to create the most realistic store possible, with the most functionalities as possible.

10:41:46 AM: build-image version: f14e228ec2dbb3d6f5ee2f499343e1468b859b97 (focal)
10:41:46 AM: buildbot version: f14e228ec2dbb3d6f5ee2f499343e1468b859b97
10:41:46 AM: Fetching cached dependencies
10:41:46 AM: Failed to fetch cache, continuing with build
10:41:46 AM: Starting to prepare the repo for build
10:41:46 AM: No cached dependencies found. Cloning fresh repo
10:41:46 AM: git clone --filter=blob:none https://github.com/HigorR456/poke-store
10:41:47 AM: Preparing Git Reference refs/heads/main
10:41:47 AM: Parsing package.json dependencies
10:41:49 AM: Starting build script
10:41:49 AM: Installing dependencies
10:41:49 AM: Python version set to 2.7
10:41:50 AM: v16.19.1 is already installed.
10:41:50 AM: Now using node v16.19.1 (npm v8.19.3)
10:41:50 AM: Enabling Node.js Corepack
10:41:50 AM: Started restoring cached build plugins
10:41:50 AM: Finished restoring cached build plugins
10:41:50 AM: Attempting Ruby version 2.7.2, read from environment
10:41:51 AM: Using Ruby version 2.7.2
10:41:51 AM: Using PHP version 8.0
10:41:51 AM: Started restoring cached corepack dependencies
10:41:51 AM: Finished restoring cached corepack dependencies
10:41:51 AM: No npm workspaces detected
10:41:51 AM: Started restoring cached node modules
10:41:51 AM: Finished restoring cached node modules
10:41:52 AM: Installing npm packages using npm version 8.19.3
10:41:57 AM: added 62 packages, and audited 63 packages in 5s
10:41:57 AM: 5 packages are looking for funding
10:41:57 AM:   run `npm fund` for details
10:41:57 AM: found 0 vulnerabilities
10:41:57 AM: npm packages installed
10:41:57 AM: Started restoring cached go cache
10:41:57 AM: Finished restoring cached go cache
10:41:57 AM: go version go1.19.7 linux/amd64
10:41:57 AM: Detected 1 framework(s)
10:41:57 AM: "next" at version "13.1.6"
10:41:57 AM: Section completed: initializing
10:41:59 AM: ​
10:41:59 AM:   Netlify Build                                                 
10:41:59 AM: ────────────────────────────────────────────────────────────────
10:41:59 AM: ​
10:41:59 AM: ❯ Version
10:41:59 AM:   @netlify/build 29.6.4
10:41:59 AM: ​
10:41:59 AM: ❯ Flags
10:41:59 AM:   baseRelDir: true
10:41:59 AM:   buildId: 64089098c64c66000884bff2
10:41:59 AM:   deployId: 64089098c64c66000884bff4
10:41:59 AM: ​
10:41:59 AM: ❯ Current directory
10:41:59 AM:   /opt/build/repo
10:41:59 AM: ​
10:41:59 AM: ❯ Config file
10:41:59 AM:   No config file was defined: using default values.
10:41:59 AM: ​
10:41:59 AM: ❯ Context
10:41:59 AM:   production
10:41:59 AM: ​
10:41:59 AM: ❯ Installing plugins
10:41:59 AM:    - @netlify/plugin-nextjs@4.31.0
10:42:10 AM: ​
10:42:10 AM: ❯ Using Next.js Runtime - v4.31.0
10:42:12 AM: ​
10:42:12 AM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
10:42:12 AM: ────────────────────────────────────────────────────────────────
10:42:12 AM: ​
10:42:12 AM: No Next.js cache to restore.
10:42:12 AM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
10:42:12 AM: ​
10:42:12 AM: (@netlify/plugin-nextjs onPreBuild completed in 16ms)
10:42:12 AM: ​
10:42:12 AM:   2. Build command from Netlify app                             
10:42:12 AM: ────────────────────────────────────────────────────────────────
10:42:12 AM: ​
10:42:12 AM: $ npm run build
10:42:12 AM: > pokemon-store@0.1.0 build
10:42:12 AM: > next build
10:42:13 AM: info  - Loaded env from /opt/build/repo/.env
10:42:13 AM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
10:42:13 AM: warn  - The `app` directory is experimental. To enable, add `appDir: true` to your `next.config.js` configuration under `experimental`. See https://nextjs.org/docs/messages/experimental-app-dir-config
10:42:13 AM: info  - Linting and checking validity of types...
10:42:16 AM: info  - Creating an optimized production build...
10:42:21 AM: Failed to compile.
10:42:21 AM: 
10:42:21 AM: ./src/pages/_app.tsx
10:42:21 AM: Module not found: Can't resolve '../styles/navigation.scss'
10:42:21 AM: https://nextjs.org/docs/messages/module-not-found
10:42:21 AM: ./src/pages/_app.tsx
10:42:21 AM: Module not found: Can't resolve '../styles/pokemon.scss'
10:42:21 AM: https://nextjs.org/docs/messages/module-not-found
10:42:21 AM: ./src/pages/_app.tsx
10:42:21 AM: Module not found: Can't resolve '../styles/title.scss'
10:42:21 AM: https://nextjs.org/docs/messages/module-not-found
10:42:21 AM: ./src/pages/_app.tsx
10:42:21 AM: Module not found: Can't resolve '../styles/navBar.scss'
10:42:21 AM: https://nextjs.org/docs/messages/module-not-found
10:42:21 AM: ./src/pages/_app.tsx
10:42:21 AM: Module not found: Can't resolve '../styles/myCart.scss'
10:42:21 AM: https://nextjs.org/docs/messages/module-not-found
10:42:21 AM: > Build failed because of webpack errors
10:42:22 AM: ​
10:42:22 AM:   "build.command" failed                                        
10:42:22 AM: ────────────────────────────────────────────────────────────────
10:42:22 AM: ​
10:42:22 AM:   Error message
10:42:22 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
10:42:22 AM: ​
10:42:22 AM:   Error location
10:42:22 AM:   In Build command from Netlify app:
10:42:22 AM:   npm run build
10:42:22 AM: ​
10:42:22 AM:   Resolved config
10:42:22 AM:   build:
10:42:22 AM:     command: npm run build
10:42:23 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
10:42:22 AM:     commandOrigin: ui
10:42:22 AM:     environment:
10:42:22 AM:       - NEXT_PRIVATE_TARGET
10:42:22 AM:     publish: /opt/build/repo/.next
10:42:22 AM:     publishOrigin: ui
10:42:22 AM:   plugins:
10:42:22 AM:     - inputs: {}
10:42:22 AM:       origin: ui
10:42:22 AM:       package: '@netlify/plugin-nextjs'
10:42:22 AM: Caching artifacts
10:42:22 AM: Started saving node modules
10:42:22 AM: Finished saving node modules
10:42:22 AM: Started saving build plugins
10:42:22 AM: Finished saving build plugins
10:42:22 AM: Started saving corepack cache
10:42:22 AM: Finished saving corepack cache
10:42:22 AM: Started saving pip cache
10:42:22 AM: Finished saving pip cache
10:42:22 AM: Started saving emacs cask dependencies
10:42:22 AM: Finished saving emacs cask dependencies
10:42:22 AM: Started saving maven dependencies
10:42:22 AM: Finished saving maven dependencies
10:42:22 AM: Started saving boot dependencies
10:42:22 AM: Finished saving boot dependencies
10:42:22 AM: Started saving rust rustup cache
10:42:22 AM: Finished saving rust rustup cache
10:42:22 AM: Started saving go dependencies
10:42:22 AM: Finished saving go dependencies
10:42:23 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:42:23 AM: Failing build: Failed to build site
10:42:23 AM: Finished processing build request in 36.791s

Filenames are case sensitive (see: [Support Guide] Netlify app builds locally but fails on deploy (case sensitivity))

For example in _app.tsx you have

import '@/styles/navigation.scss';

but you need

import '@/styles/Navigation.scss';
2 Likes

Thank you so much buddy, I was stuck with this problem the whole week, it turned out to be a problem with the case. Pokemon Store (poke-store456.netlify.app)

Thank so much for confirming this! (: