Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Saif-V opened this issue Jul 17, 2024 · 4 comments
Open

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

Saif-V opened this issue Jul 17, 2024 · 4 comments

Comments

@Saif-V
Copy link

Saif-V commented Jul 17, 2024

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
@Saif-V Saif-V changed the title uild Issues with Bun - Content Layer Error on windows Build Issues with Bun - Content Layer Error on windows Jul 17, 2024
@mickasmt
Copy link
Owner

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
Copy link
Author

Saif-V commented Jul 22, 2024

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.

@Saif-V Saif-V closed this as completed Jul 22, 2024
@Saif-V Saif-V reopened this Jul 22, 2024
@mickasmt
Copy link
Owner

@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
Copy link
Author

Saif-V commented Jul 30, 2024

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.

[email protected] dev C:\Users\saifj\OneDrive\Desktop\qr\next-saas-stripe-starter
next dev

▲ Next.js 14.2.5

✓ Starting...
✓ Ready in 8.4s
Error: Cannot find package 'C:\Users\saifj\OneDrive\Desktop\qr\next-saas-stripe-starter\node_modules.pnpm@effect-ts+otel-sdk-trace-node@0.15.1_@effect-ts+core@0.60.5_@opentelemetry+api@1.8.0_@opente_k5kjeyitrto3vllawqjmlbs5oi\node_modules@opentelemetry\sdk-trace-node\package.json' imported from C:\Users\saifj\OneDrive\Desktop\qr\next-saas-stripe-starter\node_modules.pnpm@effect-ts+otel-sdk-trace-node@0.15.1_@effect-ts+core@0.60.5_@opentelemetry+api@1.8.0_@opente_k5kjeyitrto3vllawqjmlbs5oi\node_modules@effect-ts\otel-sdk-trace-node_mjs\index.mjs
Did you mean to import @opentelemetry+sdk-trace-node@1.24.0_@opentelemetry[email protected]/node_modules/@opentelemetry/sdk-trace-node/build/src/index.js?
at legacyMainResolve (node:internal/modules/esm/resolve:205:26)
at packageResolve (node:internal/modules/esm/resolve:831:14)
at moduleResolve (node:internal/modules/esm/resolve:901:20)
at defaultResolve (node:internal/modules/esm/resolve:1121:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleWrap. (node:internal/modules/esm/module_job:85:39)
at link (node:internal/modules/esm/module_job:84:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Error: Cannot find package 'C:\Users\saifj\OneDrive\Desktop\qr\next-saas-stripe-starter\node_modules.pnpm@effect-ts+otel-sdk-trace-node@0.15.1_@effect-ts+core@0.60.5_@opentelemetry+api@1.8.0_@opente_k5kjeyitrto3vllawqjmlbs5oi\node_modules@opentelemetry\sdk-trace-node\package.json' imported from C:\Users\saifj\OneDrive\Desktop\qr\next-saas-stripe-starter\node_modules.pnpm@effect-ts+otel-sdk-trace-node@0.15.1_@effect-ts+core@0.60.5_@opentelemetry+api@1.8.0_@opente_k5kjeyitrto3vllawqjmlbs5oi\node_modules@effect-ts\otel-sdk-trace-node_mjs\index.mjs
Did you mean to import @opentelemetry+sdk-trace-node@1.24.0_@opentelemetry[email protected]/node_modules/@opentelemetry/sdk-trace-node/build/src/index.js?
at legacyMainResolve (node:internal/modules/esm/resolve:205:26)
at packageResolve (node:internal/modules/esm/resolve:831:14)
at moduleResolve (node:internal/modules/esm/resolve:901:20)
at defaultResolve (node:internal/modules/esm/resolve:1121:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleWrap. (node:internal/modules/esm/module_job:85:39)
at link (node:internal/modules/esm/module_job:84:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Error: Cannot find package 'C:\Users\saifj\OneDrive\Desktop\qr\next-saas-stripe-starter\node_modules.pnpm@effect-ts+otel-sdk-trace-node@0.15.1_@effect-ts+core@0.60.5_@opentelemetry+api@1.8.0_@opente_k5kjeyitrto3vllawqjmlbs5oi\node_modules@opentelemetry\sdk-trace-node\package.json' imported from C:\Users\saifj\OneDrive\Desktop\qr\next-saas-stripe-starter\node_modules.pnpm@effect-ts+otel-sdk-trace-node@0.15.1_@effect-ts+core@0.60.5_@opentelemetry+api@1.8.0_@opente_k5kjeyitrto3vllawqjmlbs5oi\node_modules@effect-ts\otel-sdk-trace-node_mjs\index.mjs
Did you mean to import @opentelemetry+sdk-trace-node@1.24.0_@opentelemetry[email protected]/node_modules/@opentelemetry/sdk-trace-node/build/src/index.js?
at legacyMainResolve (node:internal/modules/esm/resolve:205:26)
at packageResolve (node:internal/modules/esm/resolve:831:14)
at moduleResolve (node:internal/modules/esm/resolve:901:20)
at defaultResolve (node:internal/modules/esm/resolve:1121:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleWrap. (node:internal/modules/esm/module_job:85:39)
at link (node:internal/modules/esm/module_job:84:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Error: Cannot find package 'C:\Users\saifj\OneDrive\Desktop\qr\next-saas-stripe-starter\node_modules.pnpm@effect-ts+otel-sdk-trace-node@0.15.1_@effect-ts+core@0.60.5_@opentelemetry+api@1.8.0_@opente_k5kjeyitrto3vllawqjmlbs5oi\node_modules@opentelemetry\sdk-trace-node\package.json' imported from C:\Users\saifj\OneDrive\Desktop\qr\next-saas-stripe-starter\node_modules.pnpm@effect-ts+otel-sdk-trace-node@0.15.1_@effect-ts+core@0.60.5_@opentelemetry+api@1.8.0_@opente_k5kjeyitrto3vllawqjmlbs5oi\node_modules@effect-ts\otel-sdk-trace-node_mjs\index.mjs
Did you mean to import @opentelemetry+sdk-trace-node@1.24.0_@opentelemetry[email protected]/node_modules/@opentelemetry/sdk-trace-node/build/src/index.js?
at legacyMainResolve (node:internal/modules/esm/resolve:205:26)
at packageResolve (node:internal/modules/esm/resolve:831:14)
at moduleResolve (node:internal/modules/esm/resolve:901:20)
at defaultResolve (node:internal/modules/esm/resolve:1121:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleWrap. (node:internal/modules/esm/module_job:85:39)
at link (node:internal/modules/esm/module_job:84:36) {
code: 'ERR_MODULE_NOT_FOUND'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants