opennextjs / opennextjs-cloudflare

Open Next.js adapter for Cloudflare
https://opennext.js.org/cloudflare
MIT License
378 stars 8 forks source link

Build, Preview, and Deployment are not functioning on Windows #59

Closed palak-convivity closed 1 month ago

palak-convivity commented 1 month ago

This is what I get when I run : yarn run preview or npm run preview

package.json

{
  "name": "my-next-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "deploy": "cloudflare && wrangler deploy",
    "preview": "cloudflare && wrangler dev",
    "cf-typegen": "wrangler types --env-interface CloudflareEnv env.d.ts",
    "dev:worker": "wrangler dev --port 3000"
  },
  "dependencies": {
    "next": "14.2.5",
    "react": "^18",
    "react-dom": "^18"
  },
  "devDependencies": {
    "@cloudflare/workers-types": "^4.20240925.0",
    "@opennextjs/cloudflare": "^0.0.0-59a1d9e",
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "eslint": "^8",
    "eslint-config-next": "14.2.5",
    "postcss": "^8",
    "tailwindcss": "^3.4.1",
    "typescript": "^5",
    "wrangler": "^3.79.0"
  }
}

Error Log

yarn run preview
yarn run v1.22.21
$ cloudflare && wrangler dev
Building the Next.js app in the current folder (E:\testing\next-cloudflare-KV\KVApp)
$ E:\testing\next-cloudflare-KV\KVApp\node_modules\.bin\next build
 ⚠ Invalid next.config.mjs options detected:
 ⚠     Unrecognized key(s) in object: 'skipTrailingSlashRedirects'
 ⚠ See more info here: https://nextjs.org/docs/messages/invalid-next-config
  ▲ Next.js 14.2.5

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ✓ Collecting page data
 ✓ Generating static pages (6/6)
 ✓ Collecting build traces
 ✓ Finalizing page optimization

Route (app)                              Size     First Load JS
┌ ○ /                                    5.25 kB        92.3 kB
├ ○ /_not-found                          871 B          87.9 kB
├ ƒ /api/cache                           0 B                0 B
└ ƒ /dynamic                             136 B          87.2 kB
+ First Load JS shared by all            87 kB
  ├ chunks/23-7b0d78b6b8bdf59e.js        31.5 kB
  ├ chunks/fd9d1056-2821b0f0cabcd8bd.js  53.6 kB
  └ other shared chunks (total)          1.86 kB

○  (Static)   prerendered as static content
ƒ  (Dynamic)  server-rendered on demand

⚙️ Copying files...

# copyPackageTemplateFiles
⚙️ Bundling the worker file...

# patchWranglerDeps
# updateWebpackChunksFile
 - chunk 349.js
 - chunk 621.js
 - chunk 682.js
 - chunk 948.js
# patchRequire
# patchReadFile
# inlineNextRequire
# patchFindDir
# inlineEvalManifest
# patchCached
Worker saved in `E:\testing\next-cloudflare-KV\KVApp\.worker-next\index.mjs` 🚀

 ⛅️ wrangler 3.80.0
-------------------

Your worker has access to the following bindings:
- KV Namespaces:
  - NEXT_CACHE_WORKERS_KV: de27e0b7d3c44bd48308b4e42df1ccd0
[wrangler:inf] Ready on http://127.0.0.1:8787
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│  [b] open a browser, [d] open devtools, [l] turn off local mode, [c] clear console, [x] to exit  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
✘ [ERROR] Could not resolve "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverpages_app.js"

    .worker-next/index.mjs:25029:27:
      25029 │ ...n require("E:\testing\next-cloudflare-KV\KVApp\.worker-next\...
            ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverpages_app.js" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverpages_error.js"

    .worker-next/index.mjs:25034:27:
      25034 │ ...n require("E:\testing\next-cloudflare-KV\KVApp\.worker-next\...
            ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverpages_error.js" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverpages_document.js"

    .worker-next/index.mjs:25039:27:
      25039 │ ...n require("E:\testing\next-cloudflare-KV\KVApp\.worker-next\...
            ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverpages_document.js" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverapp_not-foundpage.js"

    .worker-next/index.mjs:25044:27:
      25044 │ ...n require("E:\testing\next-cloudflare-KV\KVApp\.worker-next\...
            ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverapp_not-foundpage.js" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverapp\favicon.ico\route.js"

    .worker-next/index.mjs:25049:27:
      25049 │ ...n require("E:\testing\next-cloudflare-KV\KVApp\.worker-next\...
            ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverapp\favicon.ico\route.js" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverapppage.js"

    .worker-next/index.mjs:25054:27:
      25054 │ ...n require("E:\testing\next-cloudflare-KV\KVApp\.worker-next\...
            ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverapppage.js" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverappdynamicpage.js"

    .worker-next/index.mjs:25059:27:
      25059 │ ...n require("E:\testing\next-cloudflare-KV\KVApp\.worker-next\...
            ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverappdynamicpage.js" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverappapicache\route.js"

    .worker-next/index.mjs:25064:27:
      25064 │ ...n require("E:\testing\next-cloudflare-KV\KVApp\.worker-next\...
            ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone.nextserverappapicache\route.js" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

✘ [ERROR] Could not resolve "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone\node_modules@opennextjscloudflareclicache-handler.mjs"

    .worker-next/index.mjs:30495:29:
      30495 │ ...it import('E:\testing\next-cloudflare-KV\KVApp\.worker-next\...
            ╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "E:\testing\next-cloudflare-KVKVApp.worker-next.nextstandalone\node_modules@opennextjscloudflareclicache-handler.mjs" as external to exclude it from the bundle, which will remo

✘ [ERROR] Failed to build

╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│  [b] open a browser, [d] open devtools, [l] turn off local mode, [c] clear console, [x] to exit  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
√ Would you like to report this error to Cloudflare? ... yes
🪵  Logs were written to "C:\Users\parvesh\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2024-10-04_12-27-27_208.log"
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
andyeskridge commented 1 month ago

I've run into this issue too. I believe it is an issue with the path that is being generated.

clansty commented 1 month ago

Seems the building stuff not understanding windows paths