cloudflare / workers-sdk

โ›…๏ธ Home to Wrangler, the CLI for Cloudflare Workersยฎ
https://developers.cloudflare.com/workers/
Apache License 2.0
2.72k stars 712 forks source link

๐Ÿ› BUG: Nuxt app fails to deploy (Uncaught TypeError: Cannot read properties of undefined (reading 'split')) #3144

Closed Skmt3P closed 1 year ago

Skmt3P commented 1 year ago

Which Cloudflare product(s) does this pertain to?

Wrangler

What version of Wrangler are you using?

2.19.0

What operating system are you using?

Linux

Describe the Bug

Details

Logs

โ›…๏ธ wrangler 2.19.0 
--------------------
Fetching list of already uploaded assets...
Building list of assets to upload...
 = // lots of files...
 = _nuxt/index.933568a5.909a4b7720.css (already uploaded _nuxt/index.933568a5.css)
   (truncating changed assets log, set `WRANGLER_LOG=debug` environment variable to see full diff)
Skipped uploading 201 existing assets.
โ†—๏ธ  Done syncing assets
Total Upload: 3563.43 KiB / gzip: 751.72 KiB

โœ˜ [ERROR] A request to the Cloudflare API (/accounts/<accoundId>/workers/scripts/<pjName>) failed.

  Uncaught TypeError: Cannot read properties of undefined (reading 'split')
    at worker.js:5439:416
    at worker.js:52758:4
    at worker.js:52759:3
   [code: 10021]

Information

CI: Github Actions / cloudflare/wrangler-action/2.0.0 Deploy to: Cloudflare workers FW: Nuxt3 (SSR preset: cloudflare) deps:

  "dependencies": {
    "@gtm-support/vue-gtm": "^2.0.0",
    "@vee-validate/zod": "4.8.6",
    "camelcase-keys": "^8.0.2",
    "dayjs": "^1.11.6",
    "markdown-it": "^13.0.1",
    "ohmyfetch": "^0.4.21",
    "ress": "^5.0.2",
    "snakecase-keys": "^5.4.4",
    "swiper": "^9.2.3",
    "universal-cookie": "^4.0.4",
    "uuid": "^9.0.0",
    "vee-validate": "^4.8.6",
    "vue-advanced-cropper": "^2.8.8",
    "vue-scrollto": "^2.20.0",
    "vue3-toastify": "^0.1.5"
  },
  "devDependencies": {
    "@headlessui/vue": "^1.7.4",
    "@inkline/inkline": "^3.2.2",
    "@inkline/nuxt": "^3.1.4",
    "@intlify/unplugin-vue-i18n": "^0.10.0",
    "@intlify/vite-plugin-vue-i18n": "^7.0.0",
    "@intlify/vue-i18n-loader": "^4.2.0",
    "@nuxt/test-utils": "^3.3.2",
    "@nuxtjs/eslint-config-typescript": "^12.0.0",
    "@nuxtjs/i18n": "^8.0.0-beta.7",
    "@nuxtjs/supabase": "^0.3.5",
    "@playwright/test": "^1.28.0",
    "@testing-library/dom": "^9.0.0",
    "@testing-library/user-event": "^14.4.3",
    "@testing-library/vue": "^7.0.0",
    "@toast-ui/editor": "^3.2.2",
    "@types/markdown-it": "^12.2.3",
    "@types/node": "^18.16.0",
    "@types/uuid": "^9.0.0",
    "@types/webpack-env": "^1.18.0",
    "@typescript-eslint/eslint-plugin": "^5.57.1",
    "@typescript-eslint/parser": "^5.59.1",
    "@vee-validate/i18n": "^4.8.6",
    "@vite-pwa/nuxt": "^0.0.7",
    "@vitejs/plugin-vue": "^4.1.0",
    "@vitest/coverage-c8": "^0.29.7",
    "@vitest/ui": "^0.30.0",
    "@vue/runtime-dom": "^3.2.45",
    "@vue/test-utils": "^2.2.3",
    "@vue/tsconfig": "^0.1.3",
    "@vueuse/core": "^10.1.0",
    "@vueuse/nuxt": "^10.0.2",
    "c8": "^7.12.0",
    "cross-env": "^7.0.3",
    "css-loader": "^6.7.2",
    "eslint": "^8.39.0",
    "eslint-config-google": "^0.14.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-import-resolver-typescript": "^3.5.2",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-n": "^15.7.0",
    "eslint-plugin-nuxt": "^4.0.0",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-promise": "^6.1.1",
    "eslint-plugin-unicorn": "^46.0.0",
    "eslint-plugin-vue": "^9.10.0",
    "fs": "^0.0.1-security",
    "husky": "^4.3.8",
    "imagemin-gifsicle": "^7.0.0",
    "imagemin-keep-folder": "^5.3.2",
    "imagemin-mozjpeg": "^10.0.0",
    "imagemin-pngquant": "^9.0.2",
    "imagemin-svgo": "^10.0.1",
    "jsdom": "^21.1.0",
    "lint-staged": "^13.0.3",
    "markdown-it": "^13.0.1",
    "msw": "^1.1.0",
    "npm-run-all": "^4.1.5",
    "nuxt": "^3.4.3",
    "postcss-html": "^1.5.0",
    "prettier": "^2.8.7",
    "sass": "^1.59.3",
    "sass-loader": "^13.2.1",
    "scaffdog": "^2.4.0",
    "stylelint": "^14.15.0",
    "stylelint-config-prettier": "^9.0.4",
    "stylelint-config-recommended": "^9.0.0",
    "stylelint-config-sass-guidelines": "^10.0.0",
    "stylelint-order": "^6.0.3",
    "stylelint-rscss": "^0.4.0",
    "swiper": "^9.2.3",
    "timers": "^0.1.1",
    "ts-loader": "^9.4.1",
    "ts-node": "^10.9.1",
    "typescript": "5.0.4",
    "unplugin-auto-import": "^0.15.1",
    "vite": "^4.3.4",
    "vite-plugin-checker": "^0.5.6",
    "vite-plugin-eslint": "^1.8.1",
    "vite-plugin-yaml": "^1.0.5",
    "vite-svg-loader": "^4.0.0",
    "vitest": "^0.30.1",
    "vue": "^3.2.45",
    "vue-advanced-cropper": "^2.8.8",
    "vue-i18n": "^9.3.0-beta.17",
    "vue-loader": "^17.1.0",
    "vue-meta": "^3.0.0-alpha.10",
    "vue-tsc": "^1.3.4",
    "wrangler": "^2.19.0",
    "yaml-loader": "^0.8.0",
    "yarn-upgrade-all": "^0.7.1",
    "zod": "^3.19.1"
  },
gbyesiltas commented 1 year ago

I have the same issue with Nuxt 3 โœ‹

I think it appears on w.versions.node.split(".")

krombout commented 1 year ago

Related issue

I am also running into the same issue here on my local machine. Happens on npx wrangler dev .output/server/index.mjs --site .output/public --local

Logs


 โ›…๏ธ wrangler 2.20.0 
--------------------
Want to try out the next version of local mode using the open-source Workers runtime?
Switch out --local for --experimental-local and let us know what you think at https://discord.gg/cloudflaredev !
โŽ” Starting a local server...
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit                                                                     โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
Debugger listening on ws://127.0.0.1:55698/75a19c6f-94c1-466c-bf32-1beacb629a76
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
[mf:err] /private/var/folders/b2/4c8sqqhj2qq_7821m00qlvfr0000gn/T/tmp-47540-V55HsMhlPBX3/index.js:5394
    const Hs = requireFs(), { Readable: zs } = requireStream(), Gs = ue, { promisify: Ks } = Hn, Ys = qs, Js = Ks(Hs.readdir), Xs = Ks(Hs.stat), Qs = Ks(Hs.lstat), Zs = Ks(Hs.realpath), ei = "READDIRP_RECURSIVE_ERROR", ti = /* @__PURE__ */ new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", ei]), ri = "files", ni = "directories", si = "files_directories", ii = "all", oi = [ri, ni, si, ii], [ai, ui] = w.versions.node.split(".").slice(0, 2).map((e2) => Number.parseInt(e2, 10)), ci = "win32" === w.platform && (ai > 10 || 10 === ai && ui >= 5), normalizeFilter = (e2) => {

TypeError: Cannot read properties of undefined (reading 'split')

    at .nuxt/dist/server/client.manifest.mjs:3922:12
    at /private/var/folders/b2/4c8sqqhj2qq_7821m00qlvfr0000gn/T/tmp-47540-V55HsMhlPBX3/index.js:28435:3
    at Script.runInContext (node:vm:141:12)
    at VMScriptRunner.runAsScript (/usr/local/lib/node_modules/wrangler/node_modules/@miniflare/runner-vm/src/index.ts:26:12)
    at VMScriptRunner.run (/usr/local/lib/node_modules/wrangler/node_modules/@miniflare/runner-vm/src/index.ts:88:12)
    at Miniflare.#reload (/usr/local/lib/node_modules/wrangler/node_modules/@miniflare/core/src/index.ts:790:42)
    at Miniflare.getPlugins (/usr/local/lib/node_modules/wrangler/node_modules/@miniflare/core/src/index.ts:1033:5)
    at createServer (/usr/local/lib/node_modules/wrangler/node_modules/@miniflare/http-server/src/index.ts:362:19)
    at startServer (/usr/local/lib/node_modules/wrangler/node_modules/@miniflare/http-server/src/index.ts:469:18)
fairok commented 1 year ago

I have the same problem. Logs:

`PS D:\Work\Dev\mx-ys-clientweb> wrangler dev .output/server/index.mjs --site .output/public --local โ›…๏ธ wrangler 3.0.0

wrangler dev now uses local mode by default, powered by ๐Ÿ”ฅ Miniflare and ๐Ÿ‘ท workerd. To run an edge preview session for your Worker, use wrangler dev --remote โ–ฒ [WARNING] --local is no longer required and will be removed in a future version.

wrangler dev now uses the local Cloudflare Workers runtime by default. ๐ŸŽ‰

โŽ” Starting local server... service core:user:hello-world-icy-art-695a: Uncaught TypeError: Cannot read properties of undefined (reading 'split') at core:user:hello-world-icy-art-695a:5706:416 at core:user:hello-world-icy-art-695a:45366:4 at core:user:hello-world-icy-art-695a:45367:3 โœ˜ [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎโ”‚ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit โ”‚โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏโŽ” Shutting down local server... PS D:\Work\Dev\mx-ys-clientweb> wrangler dev โ›…๏ธ wrangler 3.0.0

wrangler dev now uses local mode by default, powered by ๐Ÿ”ฅ Miniflare and ๐Ÿ‘ท workerd. To run an edge preview session for your Worker, use wrangler dev --remote โŽ” Starting local server... service core:user:hello-world-icy-art-695a: Uncaught TypeError: Cannot read properties of undefined (reading 'split') at core:user:hello-world-icy-art-695a:5706:416 at core:user:hello-world-icy-art-695a:45366:4 at core:user:hello-world-icy-art-695a:45367:3 โœ˜ [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎโ”‚ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit โ”‚โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ`

Skmt3P commented 1 year ago

When this problem is solved...

 โ›…๏ธ wrangler 3.0.1
------------------
wrangler dev now uses local mode by default, powered by ๐Ÿ”ฅ Miniflare and ๐Ÿ‘ท workerd.
To run an edge preview session for your Worker, use wrangler dev --remote
โŽ” Starting local server...
service core:user:worker: Uncaught TypeError: Cannot read properties of undefined (reading 'split')
  at ivsvnonyb4d.js:4962:32
โœ˜ [ERROR] MiniflareCoreError [ERR_RUNTIME_FAILURE]: The Workers runtime failed to start. There is likely additional logging output above.
LeonardoRick commented 1 year ago

I'm facing the same error on wrangler 3.1.0 it's actually being pretty hard to deploy my first nuxt application on cloudflare

penalosa commented 1 year ago

Nuxt apps should work in Cloudflare Workers both locally and when deployed. The steps at https://nitro.unjs.io/deploy/providers/cloudflare or https://developers.cloudflare.com/pages/framework-guides/deploy-a-nuxt-site/ should work for either Cloudflare Workers or Cloudflare Pages.

If you're still running into issues, would you be able to open a new issue with a sample repo that shows the problem?