Next js deploy first fine, then face build stage problems when redeploy

As I Mentioned in the title, I deployed a next js project, the first time it worked fine. But when I made changes on my code and redeploy the project, I face this problem. I tried to change the build command to CI= npm run build and added the variable CI = false, but the problem still the same. here is the log:

10:23:07 AM: $ npm run build
10:23:07 AM: > client@0.1.0 build
10:23:07 AM: > next build
10:23:08 AM: ▲ Next.js 14.1.4
10:23:08 AM: - Environments: .env
10:23:08 AM: Creating an optimized production build …
10:23:16 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:23:16 AM: Failed to compile.
10:23:16 AM:
10:23:16 AM: src/app/layout.tsx
10:23:16 AM: An error occured in next/font.
10:23:16 AM: Error: Cannot find module ‘autoprefixer’
10:23:16 AM: Require stack:
10:23:16 AM: - /opt/build/repo/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js
10:23:16 AM: - /opt/build/repo/node_modules/next/dist/build/webpack/config/blocks/css/index.js
10:23:16 AM: - /opt/build/repo/node_modules/next/dist/build/webpack/config/index.js
10:23:16 AM: - /opt/build/repo/node_modules/next/dist/build/webpack-config.js
10:23:16 AM: - /opt/build/repo/node_modules/next/dist/build/webpack-build/impl.js
10:23:16 AM: - /opt/build/repo/node_modules/next/dist/compiled/jest-worker/processChild.js
10:23:16 AM: at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
10:23:16 AM: at /opt/build/repo/node_modules/next/dist/server/require-hook.js:55:36
10:23:16 AM: at Function.resolve (node:internal/modules/cjs/helpers:116:19)
10:23:16 AM: at loadPlugin (/opt/build/repo/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js:49:32)
10:23:16 AM: at /opt/build/repo/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js:157:56
10:23:16 AM: at Array.map ()
10:23:16 AM: at getPostCssPlugins (/opt/build/repo/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js:157:47)
10:23:16 AM: at async /opt/build/repo/node_modules/next/dist/build/webpack/config/blocks/css/index.js:124:36
10:23:16 AM: at async /opt/build/repo/node_modules/next/dist/build/webpack/loaders/next-font-loader/index.js:86:33
10:23:16 AM: at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:151:20)
10:23:16 AM: ./src/app/(components)/AuthPanels/AuthPanels.tsx
10:23:16 AM: Module not found: Can’t resolve ‘@/components/ui/button’
10:23:16 AM: Module Not Found | Next.js
10:23:16 AM: ./src/app/(components)/AuthPanels/AuthPanels.tsx
10:23:16 AM: Module not found: Can’t resolve ‘@/components/ui/input’
10:23:16 AM: Module Not Found | Next.js
10:23:16 AM: ./src/app/(components)/AuthPanels/AuthPanels.tsx
10:23:16 AM: Module not found: Can’t resolve ‘@/components/ui/label’
10:23:16 AM: Module Not Found | Next.js
10:23:16 AM: ./src/app/(components)/CustomDrawer/CustomPhoneDrawer.tsx
10:23:16 AM: Module not found: Can’t resolve ‘@/components/ui/drawer’
10:23:16 AM: Module Not Found | Next.js
10:23:16 AM: > Build failed because of webpack errors
10:23:16 AM: ​
10:23:16 AM: @netlify/plugin-nextjs (onEnd event)
10:23:16 AM: ────────────────────────────────────────────────────────────────
10:23:16 AM: ​
10:23:16 AM: ​
10:23:16 AM: (@netlify/plugin-nextjs onEnd completed in 7ms)
10:23:16 AM: ​
10:23:16 AM: “build.command” failed
10:23:16 AM: ────────────────────────────────────────────────────────────────
10:23:16 AM: ​
10:23:16 AM: Error message
10:23:16 AM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
10:23:16 AM: ​
10:23:16 AM: Error location
10:23:16 AM: In Build command from Netlify app:
10:23:16 AM: npm run build
10:23:16 AM: ​
10:23:16 AM: Resolved config
10:23:16 AM: build:
10:23:16 AM: command: npm run build
10:23:16 AM: commandOrigin: ui
10:23:16 AM: environment:
10:23:16 AM: - BASE_URL
10:23:16 AM: - BASE_URL_ASSETS
10:23:16 AM: - CI
10:23:16 AM: - CLIENT_BASE_URL
10:23:16 AM: - MAIN_CATEGORY_CACHE
10:23:16 AM: - NODE_ENV
10:23:16 AM: - NODE_VERSION
10:23:16 AM: - PHONE_CATEGORY_CACHE
10:23:16 AM: - WORDS_CACHE
10:23:16 AM: publish: /opt/build/repo/.next
10:23:16 AM: publishOrigin: ui
10:23:16 AM: plugins:
10:23:16 AM: - inputs: {}
10:23:16 AM: origin: ui
10:23:16 AM: package: ‘@netlify/plugin-nextjs’
10:23:16 AM: redirects:
10:23:16 AM: - force: true
10:23:16 AM: from: /_next/image/*
query:
q: ‘:quality’
url: ‘:url’
w: ‘:width’
status: 200
to: /.netlify/images?url=:url&w=:width&q=:quality
redirectsOrigin: config
10:23:16 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:23:16 AM: Failing build: Failed to build site
10:23:16 AM: Finished processing build request in 32.119s

and thank you all for your time and effort for helping me

Setting CI to false isn’t a magic bullet solution to fixing builds and ignoring errors.
It only prevents warnings from being treated as errors.

If you read your build log, you will see it’s not throwing a warning, but an actual error:

Check to ensure that autoprefixer is defined as a dependency in your package.json