Hebilicious/form-actions-nuxt

module doesn't work on windows

Closed this issue · 4 comments

Environment

Nuxt project info:


  • Operating System: Windows_NT
  • Node Version: v20.9.0
  • Nuxt Version: 3.8.0
  • CLI Version: 3.9.1
  • Nitro Version: 2.6.2
  • Package Manager: pnpm@8.10.1
  • Builder: -
  • User Config: devtools, modules, googleFonts
  • Runtime Modules: @nuxt/ui@2.10.0, @nuxtjs/tailwindcss@6.8.1, @nuxtjs/google-fonts@3.0.2, @nuxt/image@1.0.0, @vueuse/nuxt@10.5.0, @hebilicious/form-actions-nuxt@0.2.4, nuxt-icon@0.6.1
  • Build Modules: -

Reproduction

Try to reproduce the example on https://form-actions-nuxt.pages.dev/usage/form-actions page.

Describe the bug

The following error is called : ERROR Cannot start nuxt: Could not parse action route from C:\path\to\project\server\actions\login.ts

Additional context

No response

Logs

ERROR  Cannot start nuxt:  Could not parse action route from C:\path\to\project\server\actions\index.ts                                                                                                                                18:26:01  

  at getActionRoute (/C:\path\to\project/node_modules/.pnpm/@hebilicious+form-actions-nuxt@0.2.4_h3@1.8.2_nitropack@2.6.2_nuxt@3.8.0_vite@4.5.0_vue@3.3.7/node_modules/@hebilicious/form-actions-nuxt/dist/module.mjs:15:11)
  at /C:\path\to\project/node_modules/.pnpm/@hebilicious+form-actions-nuxt@0.2.4_h3@1.8.2_nitropack@2.6.2_nuxt@3.8.0_vite@4.5.0_vue@3.3.7/node_modules/@hebilicious/form-actions-nuxt/dist/module.mjs:159:27
  at async initNitro (/C:\path\to\project/node_modules/.pnpm/nuxt@3.8.0_vite@4.5.0/node_modules/nuxt/dist/index.mjs:2833:3)
  at async initNuxt (/C:\path\to\project/node_modules/.pnpm/nuxt@3.8.0_vite@4.5.0/node_modules/nuxt/dist/index.mjs:3684:3)
  at async NuxtDevServer._load (/C:\path\to\project/node_modules/.pnpm/nuxi@3.9.1/node_modules/nuxi/dist/chunks/dev2.mjs:255:5)
  at async NuxtDevServer.load (/C:\path\to\project/node_modules/.pnpm/nuxi@3.9.1/node_modules/nuxi/dist/chunks/dev2.mjs:187:7)
  at async NuxtDevServer.init (/C:\path\to\project/node_modules/.pnpm/nuxi@3.9.1/node_modules/nuxi/dist/chunks/dev2.mjs:182:5)
  at async Object.run (/C:\path\to\project/node_modules/.pnpm/nuxi@3.9.1/node_modules/nuxi/dist/chunks/dev-child.mjs:103:5)
  at async runCommand$1 (/C:\path\to\project/node_modules/.pnpm/nuxi@3.9.1/node_modules/nuxi/dist/shared/nuxi.c6444792.mjs:1647:7)
  at async runCommand$1 (/C:\path\to\project/node_modules/.pnpm/nuxi@3.9.1/node_modules/nuxi/dist/shared/nuxi.c6444792.mjs:1638:11)

I took the time to read the source code a bit and realized that your regex did not include Windows support.

I just adapted the two regex functions getActionRoute() and getLoaderRoute().

I also removed the ":" character from the virtual:loader-types.d.ts file and changed it with ".". I didn't find any usage reported in the module, don't hesitate to modify that if necessary. Just know, if you forgot or didn't know, that the ":" character is prohibited in Windows paths. Thanks Microsoft :)

Thank you in any case for this module and for the review of the PR ;)

Another problem detected yesterday but I didn't have time to report it. It's clear that this is a Windows compatibility issue and despite the time I've spent trying to find the problem, I don't know where it comes from.

image

The only thing I'm sure of is that it came from your library. I tried starting a new nuxt project with just your library and it threw the above error. For your information, z: is just one of my disks.

I'm available to answer your questions if needed.

Thank you for your time.

Hi Evan, I'll comment on your PR directly.

To investigate this 2nd bug, could you please look at your node modules directory ? Within the form-action-nuxt dist files, go through the source code and see if there's any path that isn't windows friendly being referenced.

Hi Hebilicious,

I think that the second bug is strictly related to the first bug. I haven't saw in my console that the following warn was printed : " WARN "Z:directpathtoprojectfolderwithoutantislashserveractionsindex.ts" is imported by "virtual:#internal/nitro/virtual/server-handlers", but could not be resolved – treating it as an external dependency."

After explored your package's folder inside my node_modules folder, the unique file that isn't correctly referenced by Windows is the file that you talked inside the PR.

Hope I can use your package correctly without having to switch on a Unix filesystems next time you release a new version including my "fix" haha !

Thanks for your time.
Regards