prisma / blogr-nextjs-prisma

111 stars 83 forks source link

"Collecting page data ...Error: Cannot find module '../lib/prisma'" error - Build error - Can't deploy! #36

Open prtpj1 opened 7 months ago

prtpj1 commented 7 months ago

Hi, I'm really trying to finish this tutorial, but there are a few issues in it.

I though I would finish it, I was near, the final steps, THE DEPLOY, BUT I was wrong.

After try the deploy following tutorial instructions I tried build locally.

And I got this error:

npm run build

> hello-next@1.0.0 build
> next build

 ✓ Linting and checking validity of types
   ▲ Next.js 14.0.4
   - Environments: .env

 ✓ Creating an optimized production build
 ✓ Compiled successfully
   Collecting page data  ...Error: Cannot find module '../lib/prisma'
Require stack:
- /home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/.next/server/pages/dist/drafts.js- /home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/server/require.js
- /home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/server/load-components.js
- /home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/build/utils.js
- /home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/build/worker.js
- /home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/compiled/jest-worker/processChild.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at /home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/server/require-hook.js:55:36
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at mod.require (/home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/server/require-hook.js:65:28)
    at require (node:internal/modules/cjs/helpers:121:18)
    at 1164 (/home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/.next/server/pages/dist/drafts.js:1:1838)
    at o (/home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/.next/server/webpack-runtime.js:1:127)
    at r (/home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/.next/server/pages/dist/drafts.js:1:5274)
    at /home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/.next/server/pages/dist/drafts.js:1:5301 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/.next/server/pages/dist/drafts.js',
    '/home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/server/require.js',
    '/home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/server/load-components.js',
    '/home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/build/utils.js',
    '/home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/build/worker.js',
    '/home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/compiled/jest-worker/processChild.js'
  ]
}

> Build error occurred
Error: Failed to collect page data for /dist/drafts
    at /home/prtpj/Trybe_U/Projetos/tutoriais/react/blogr-nextjs-prisma/node_modules/next/dist/build/utils.js:1220:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  type: 'Error'
}
   Collecting page data  .%

I did a few searchs and I tried: rm -rf node_modules npm install npm install prisma@latest

I found this topics about it: https://github.com/prisma/prisma/discussions/22374 https://github.com/prisma/prisma/discussions/21861

Then I tried and updated typescript to 5.2.2, but nothing worked. Screenshot_347

There are other ways to try fix this issue?

larry-xue commented 6 months ago

I believe the error you're encountering stems from using next@14, which introduces some breaking changes compared to next@12. The guide you're following is written for version next@12. You might want to consider downgrading to a lower version of next for compatibility.

image

prtpj1 commented 6 months ago

I believe the error you're encountering stems from using next@14, which introduces some breaking changes compared to next@12. The guide you're following is written for version next@12. You might want to consider downgrading to a lower version of next for compatibility.

image

Hi Larry

Thx for reply. I thought about downgrade, but as its a nextjs official tutorial I was hoping I could finish it even on a version superior to next12

So is it impossible or too much complicated?

And since there were breaking changes, the structure changes between 12 and 13...is it possible to do the downgrade from 14 to 12 without break everything? Or I need to restart the tutorial using next12??

larry-xue commented 6 months ago

Hi Paulo,

You can take a look at the upgrade guide for nextjs first, and then decide whether to continue in the next@14.

I think you can downgrade to version 12 first and then consider upgrading after completing the tutorial. If you haven't been learn next before, it will be difficult to handle version compatibility issues while studying the tutorial.

I hope these can help you https://nextjs.org/docs/pages/building-your-application/upgrading

prtpj1 commented 6 months ago

Hi Paulo,

You can take a look at the upgrade guide for nextjs first, and then decide whether to continue in the next@14.

I think you can downgrade to version 12 first and then consider upgrading after completing the tutorial. If you haven't been learn next before, it will be difficult to handle version compatibility issues while studying the tutorial.

I hope these can help you https://nextjs.org/docs/pages/building-your-application/upgrading

I will think what path I will get. I'm learning next and this was my second tutorial :D

Thx for the help...