Can't deploy(Deploy failed due to an error in @netlify/plugin-nextjs plugin.)

I can’t deploy my page. I used ReactJS to build the page. When deployed it, it false at building part.

here is some of the information, please help. Even ChatGPT, still can’t fix it.
I can run npm run build in VScode.Node.js version is v21.2.0

Deploy summary

  • Plugin “@netlify/plugin-nextjs” failed

Error: The directory “/opt/build/repo/build” does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory. In most cases it should be set to “.next”, unless you have chosen a custom “distDir” in your Next config. If you are using “next export” then you should set the environment variable NETLIFY_NEXT_PLUGIN_SKIP to "true

2:31:05 AM: (build.command completed in 25.1s)
2:31:05 AM: ​
2:31:05 AM: @netlify/plugin-nextjs (onBuild event)
2:31:05 AM: ────────────────────────────────────────────────────────────────
2:31:05 AM: ​
2:31:05 AM: ​
2:31:05 AM: Plugin “@netlify/plugin-nextjs” failed
2:31:05 AM: ────────────────────────────────────────────────────────────────
2:31:05 AM: ​
2:31:05 AM: Error message
2:31:05 AM: Error: The directory “/opt/build/repo/build” does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory.
2:31:05 AM: In most cases it should be set to “.next”, unless you have chosen a custom “distDir” in your Next config.
2:31:05 AM: If you are using “next export” then you should set the environment variable NETLIFY_NEXT_PLUGIN_SKIP to “true”.
2:31:05 AM: ​
2:31:05 AM: Plugin details
2:31:05 AM: Package: @netlify/plugin-nextjs
2:31:05 AM: Version: 4.41.2
2:31:05 AM: Repository: git+https://github.com/netlify/next-runtime.git
2:31:05 AM: npm link: @netlify/plugin-nextjs - npm
2:31:05 AM: Report issues: Issues · netlify/next-runtime · GitHub
2:31:05 AM: ​
2:31:05 AM: Error location
2:31:05 AM: In “onBuild” event in “@netlify/plugin-nextjs” from Netlify app and package.json
2:31:05 AM: ​
2:31:05 AM: Resolved config
2:31:05 AM: build:
2:31:05 AM: command: CI= npm run build
2:31:05 AM: commandOrigin: ui
2:31:05 AM: environment:
2:31:05 AM: - CI
2:31:05 AM: - NPM_FLAGS
2:31:05 AM: - NEXT_PRIVATE_TARGET
2:31:05 AM: publish: /opt/build/repo/build
2:31:05 AM: publishOrigin: ui
2:31:05 AM: plugins:
2:31:05 AM: - inputs: {}
2:31:05 AM: origin: ui
2:31:05 AM: package: “@netlify/plugin-nextjs”
2:31:05 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:31:05 AM: Failing build: Failed to build site
2:31:06 AM: Finished processing build request in 59.73s

musical-marshmallow-fbe744

Hi @allen, welcome and thanks for the post.
Kindly check the resource below on how to properly configure your Next.js application for Netlify since the error you are getting indicates that you specified the wrong publish directory.

Thanks.