It is my first time building a react app with NextJS frameword. The website ran ok locally with npm run build
or npm run dev
but got errors when I was trying to deploy it on Vercel.
Here is the log:
[12:51:06.189] Running build in Washington, D.C., USA (East) – iad1
[12:51:06.234] Cloning github.com/tym1226/nextjs-personal-blog (Branch: master, Commit: 2d9acfd)
[12:51:06.542] Previous build cache not available
[12:51:11.849] Cloning completed: 5.614s
[12:51:13.255] Running "vercel build"
[12:51:13.827] Vercel CLI 28.16.12
[12:51:14.166] Installing dependencies...
[12:51:16.299]
[12:51:16.299] added 2 packages in 2s
[12:51:16.299]
[12:51:16.299] 66 packages are looking for funding
[12:51:16.300] run `npm fund` for details
[12:51:16.315] Detected Next.js version: 12.3.4
[12:51:16.317] Running "CI=' ' npm run build"
[12:51:16.699]
[12:51:16.699] > nextjs-course@0.1.0 build
[12:51:16.699] > next build
[12:51:16.699]
[12:51:17.324] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[12:51:17.324] This information is used to shape Next.js' roadmap and prioritize features.
[12:51:17.325] 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:
[12:51:17.325] https://nextjs.org/telemetry
[12:51:17.325]
[12:51:17.490] info - Linting and checking validity of types...
[12:51:17.676] info - Creating an optimized production build...
[12:51:29.592] info - Compiled successfully
[12:51:29.606] info - Collecting page data...
[12:51:29.975] unhandledRejection Error: Cannot find module 'next/dist/shared/lib/router/utils/resolve-href.js'
[12:51:29.976] Require stack:
[12:51:29.976] - /vercel/path0/.next/server/pages/_app.js
[12:51:29.976] - /usr/local/share/.config/yarn/global/node_modules/next/dist/server/require.js
[12:51:29.977] - /usr/local/share/.config/yarn/global/node_modules/next/dist/server/load-components.js
[12:51:29.977] - /usr/local/share/.config/yarn/global/node_modules/next/dist/export/worker.js
[12:51:29.977] - /usr/local/share/.config/yarn/global/node_modules/next/dist/build/worker.js
[12:51:29.978] - /usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/jest-worker/processChild.js
[12:51:29.978] at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)
[12:51:29.978] at mod._resolveFilename (/usr/local/share/.config/yarn/global/node_modules/next/dist/build/webpack/require-hook.js:23:32)
[12:51:29.979] at Module._load (node:internal/modules/cjs/loader:885:27)
[12:51:29.979] at Module.require (node:internal/modules/cjs/loader:1105:19)
[12:51:29.979] at require (node:internal/modules/cjs/helpers:103:18)
[12:51:29.980] at 7782 (/vercel/path0/.next/server/pages/_app.js:285:18)
[12:51:29.980] at __webpack_require__ (/vercel/path0/.next/server/webpack-runtime.js:25:42)
[12:51:29.980] at 9170 (/vercel/path0/.next/server/chunks/515.js:97:20)
[12:51:29.981] at __webpack_require__ (/vercel/path0/.next/server/webpack-runtime.js:25:42)
[12:51:29.981] at 1515 (/vercel/path0/.next/server/chunks/515.js:560:18) {
[12:51:29.982] type: 'Error',
[12:51:29.982] code: 'MODULE_NOT_FOUND',
[12:51:29.982] requireStack: [
[12:51:29.983] '/vercel/path0/.next/server/pages/_app.js',
[12:51:29.983] '/usr/local/share/.config/yarn/global/node_modules/next/dist/server/require.js',
[12:51:29.983] '/usr/local/share/.config/yarn/global/node_modules/next/dist/server/load-components.js',
[12:51:29.984] '/usr/local/share/.config/yarn/global/node_modules/next/dist/export/worker.js',
[12:51:29.985] '/usr/local/share/.config/yarn/global/node_modules/next/dist/build/worker.js',
[12:51:29.985] '/usr/local/share/.config/yarn/global/node_modules/next/dist/compiled/jest-worker/processChild.js'
[12:51:29.986] ]
[12:51:29.986] }
[12:51:30.046] Error: Command "CI=' ' npm run build" exited with 1
I tried the following after searching for similar issues but the two errors shown in the log would not go away:
- removing the .next folder or node_modules folder
- override the Build command and write CI='' npm run build