I am developing a Next.js app that work locally. But when I deploy im getting this error.
Vercel Deployment Error: Command "npm run build" exited with 1
This is my building log -
[08:26:17.892] Cloning github.com/Bossman556/TechMoneyLlc (Branch: main, Commit: 1fdf14b)
[08:26:17.899] The cli flag --force was set. Skipping build cache download.
[08:26:20.729] Cloning completed: 2.837s
[08:26:21.188] Not using Build Cache
[08:26:21.242] Running "vercel build"
[08:26:21.887] Vercel CLI 28.4.14
[08:26:22.295] Detected `package-lock.json` generated by npm 7 ...
[08:26:22.306] Installing dependencies...
[08:26:40.266] npm WARN deprecated [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
[08:26:44.660]
[08:26:44.661] added 518 packages in 22s
[08:26:44.661]
[08:26:44.661] 95 packages are looking for funding
[08:26:44.661] run `npm fund` for details
[08:26:44.687] Detected Next.js version: 12.3.1
[08:26:44.694] Running "npm run build"
[08:26:45.093]
[08:26:45.094] > [email protected] build
[08:26:45.094] > next build
[08:26:45.094]
[08:26:45.684] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[08:26:45.685] This information is used to shape Next.js' roadmap and prioritize features.
[08:26:45.685] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[08:26:45.685] https://nextjs.org/telemetry
[08:26:45.685]
[08:26:45.831] info - Linting and checking validity of types...
[08:26:46.346] error - ESLint: Failed to load config "next/babel" to extend from. Referenced from: /vercel/path0/.eslintrc.json
[08:26:49.527] info - Creating an optimized production build...
[08:26:49.891] info - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
[08:26:50.658] info - Using external babel configuration from /vercel/path0/.babelrc
[08:27:08.485] info - Compiled successfully
[08:27:08.486] info - Collecting page data...
[08:27:12.880]
[08:27:12.880] > Build optimization failed: found page without a React Component as default export in
[08:27:12.880] pages/vidsForCourses/VideoPlayer
[08:27:12.881]
[08:27:12.881] See https://nextjs.org/docs/messages/page-without-valid-component for more info.
[08:27:12.881]
[08:27:12.942] Error: Command "npm run build" exited with 1
I have tried solutions like setting environment variable CI to false
CI = false
As well I have tried
In the "Build & Development Settings", override the Build command and write CI='' npm run build.
I have dropped the node verson aswell but that did not work.
CodePudding user response:
On the logs, you are having a component which may only export but not export default. And please remove the components inside the Pages folder, create a Components folder outside the Pages folder and move your components inside the folder.
Inside pages/vidsForCourses/VideoPlayer
make sure you export default
const VideoPlayer = () => {
return <div>Your contents</div>
}
//your code might be
//export VideoPlayer;
//To fix, add "default" on your export
export default VideoPlayer;
CodePudding user response:
'found page without a React Component as default export in pages/vidsForCourses/VideoPlayer'
Was causing the error. I used this solution