I got the error when try to deploy my nextjs application on netlify

8:32:46 PM: ​
8:32:46 PM: $ npm run build
8:32:46 PM: > furnitureland@0.1.0 build
8:32:46 PM: > next build
8:32:47 PM: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: no-cache | Next.js
8:32:47 PM: info - Linting and checking validity of types…
8:32:48 PM: info - Creating an optimized production build…
8:32:55 PM: Failed to compile.
8:32:55 PM:
8:32:55 PM: ./Components/Header.js
8:32:55 PM: Module not found: Can’t resolve ‘next/Link’ in ‘/opt/build/repo/Components’
8:32:55 PM: Import trace for requested module:
8:32:55 PM: ./Components/Header.js
8:32:55 PM: > Build failed because of webpack errors
8:32:55 PM: ​
8:32:55 PM: “build.command” failed
8:32:55 PM: ────────────────────────────────────────────────────────────────
8:32:55 PM: ​
8:32:55 PM: Error message
8:32:55 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
8:32:55 PM: ​
8:32:55 PM: Error location
8:32:55 PM: In Build command from Netlify app:
8:32:55 PM: npm run build
8:32:55 PM: ​
8:32:55 PM: Resolved config
8:32:55 PM: build:
8:32:55 PM: command: npm run build
8:32:55 PM: commandOrigin: ui
8:32:55 PM: environment:
8:32:55 PM: - EMAIL_PORT
8:32:55 PM: - HOST
8:32:55 PM: - Jwt_Secret_key
8:32:55 PM: - PASS
8:32:55 PM: - USER
8:32:55 PM: - NEXT_PRIVATE_TARGET
8:32:55 PM: publish: /opt/build/repo/.next
8:32:55 PM: publishOrigin: ui
8:32:55 PM: plugins:
8:32:55 PM: - inputs: {}
8:32:56 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
8:32:55 PM: origin: ui
8:32:55 PM: package: ‘@netlify/plugin-nextjs’
8:32:55 PM: Caching artifacts
8:32:55 PM: Started saving node modules
8:32:55 PM: Finished saving node modules
8:32:55 PM: Started saving build plugins
8:32:55 PM: Finished saving build plugins
8:32:55 PM: Started saving corepack cache
8:32:55 PM: Finished saving corepack cache
8:32:55 PM: Started saving pip cache
8:32:55 PM: Finished saving pip cache
8:32:55 PM: Started saving emacs cask dependencies
8:32:55 PM: Finished saving emacs cask dependencies
8:32:55 PM: Started saving maven dependencies
8:32:55 PM: Finished saving maven dependencies
8:32:55 PM: Started saving boot dependencies
8:32:55 PM: Finished saving boot dependencies
8:32:55 PM: Started saving rust rustup cache
8:32:55 PM: Finished saving rust rustup cache
8:32:55 PM: Started saving go dependencies
8:32:55 PM: Finished saving go dependencies
8:32:56 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:32:56 PM: Failing build: Failed to build site
8:32:56 PM: Finished processing build request in 43.674s

Hiya, sorry you are having trouble.

This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem :slight_smile: Additionally, this Support Guide houses all of our resources for debugging build and deploy issues.

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!