mickasmt / next-saas-stripe-starter

Open-source SaaS Starter with User Roles & Admin Panel. Built using Next.js 14, Prisma, Neon, Auth.js v5, Resend, React Email, Shadcn/ui, Stripe, Server Actions.
https://next-saas-stripe-starter.vercel.app
MIT License
1.95k stars 354 forks source link

Build Issues with Bun - Content Layer Error on windows #47

Open Saif-V opened 4 months ago

Saif-V commented 4 months ago

I am encountering an issue when trying to build the project using Bun. The error seems to be related to the content layer.

Steps to Reproduce:

Clone the repository. Navigate to the project directory. Run the build command using Bun (bun build). Expected Behavior:

The project should build successfully without any errors.

Actual Behavior:

The build process fails with an error related to the content layer.

Additional Information:

Bun version: 1.1.17 Operating system: Windows 11 Node.js version: v20.10.0 Any help to resolve this issue would be greatly appreciated.

Thank you!

Error Message

C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production>bun run build
$ next build
  ▲ Next.js 14.2.4
  - Environments: .env.local

   Creating an optimized production build ...
Warning: Contentlayer might not work as expected on Windows
Generated 19 documents in .contentlayer
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ⚠ Using edge runtime on a page currently disables static generation for that page
 ✓ Collecting page data
   Generating static pages (11/38)  [=== ]TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7) {
  digest: '4293419188'
}
TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390) {
  digest: '1748019194'
}
TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390) {
  digest: '1748019194'
}
   Generating static pages (24/38)  [ ===]TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7) {
  digest: '4293419188'
}
TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390) {
  digest: '1748019194'
}
TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390) {
  digest: '1748019194'
}

Error occurred prerendering page "/blog/preview-mode-headless-cms". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7)
TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390) {
  digest: '1748019194'
}
TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7) {
  digest: '4293419188'
}
TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7) {
  digest: '4293419188'
}

Error occurred prerendering page "/blog/server-client-components". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7)
TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7) {
  digest: '4293419188'
}
TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390) {
  digest: '1748019194'
}

Error occurred prerendering page "/blog/deploying-next-apps". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390)
TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390) {
  digest: '1748019194'
}

Error occurred prerendering page "/blog/dynamic-routing-static-regeneration". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of undefined (reading 'slug')
    at C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6426
    at Array.map (<anonymous>)
    at j (C:\Users\saifj\OneDrive\Desktop\New folder\Entaji\Entaji - First Production\.next\server\app\(marketing)\(blog-post)\blog\[slug]\page.js:1:6390)
    at runNextTicks (node:internal/process/task_queues:60:5)
    at listOnTimeout (node:internal/timers:540:9)
    at process.processTimers (node:internal/timers:514:7)
 ✓ Generating static pages (38/38)

> Export encountered errors on following paths:
        /(marketing)/(blog-post)/blog/[slug]/page: /blog/deploying-next-apps
        /(marketing)/(blog-post)/blog/[slug]/page: /blog/dynamic-routing-static-regeneration
        /(marketing)/(blog-post)/blog/[slug]/page: /blog/preview-mode-headless-cms
        /(marketing)/(blog-post)/blog/[slug]/page: /blog/server-client-components
error: script "build" exited with code 1
mickasmt commented 4 months ago

Hi @Saif-V, sorry for the delay. I don't use Bun for my projects (only pnpm), so I can't specifically address this error. However, Contentlayer2 was recently updated last week. You can check it here. I have updated the repo. Can you retry and give me your feedback if it still doesn't work, please?

Saif-V commented 4 months ago

Hello @mickasmt,

Thank you for getting back to me. I cloned the project again, installed it, and attempted to build using both Bun and pnpm. Unfortunately, the same issue persists. I suspect the problem might be related to Contentlayer not being fully supported on Windows.

mickasmt commented 4 months ago

@Saif-V Could you retry using npm or pnpm please? I want to see if you encounter the same error or a different one. This could be the same problems as these: #28 #39

Saif-V commented 3 months ago

I tried every single solution. I tried npm and pnpm, and now it shows other errors when I try doing pnpm run dev or npm run dev on the newest update, but on version 1.0.0 everything works fine, even building.

saas-starter@0.3.1 dev C:\Users\saifj\OneDrive\Desktop\qr\next-saas-stripe-starter next dev

▲ Next.js 14.2.5