fastify / fastify-vite

Fastify plugin for Vite integration.
MIT License
849 stars 71 forks source link

[react][windows] React Starter Template does not start on Windows #132

Closed niicojs closed 6 months ago

niicojs commented 7 months ago

Prerequisites

Fastify version

4.25.2

Plugin version

5.0.6(@fastify/react@0.3.0)

Node.js version

v20.10.0

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

22H2

Description

I've just scaffold react-base template according to doc, pnpm i installed it and I got an error starting it.


> dev
> node server.js --dev

11:46:47 [vite] Pre-transform error: Failed to load url ./<path-to-project>/client/pages/index.jsx (resolved id: ./<path-to-project>/C:/<path-to-project>/client/pages/index.jsx) in /:routes.js. Does the file exist?
11:46:47 [vite] Error when evaluating SSR module /:routes.js: failed to import "./<path-to-project>/C:/Users/myname/Code/myproject/client/pages/index.jsx"
|- Error: Failed to load url ./Users/myname/Code/myproject/C:/Users/myname/Code/myproject/client/pages/index.jsx (resolved id: ./Users/myname/Code/myproject/C:/Users/myname/Code/myproject/client/pages/index.jsx) in /:routes.js. Does the file exist?
    at loadAndTransform (file:///C:/Users/myname/Code/myproject/node_modules/.pnpm/vite@5.0.11/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:49731:21)
    at async instantiateModule (file:///C:/Users/myname/Code/myproject/node_modules/.pnpm/vite@5.0.11/node_modules/vite/dist/node/chunks/dep-V3BH7oO1.js:50759:10)

Steps to Reproduce

pnpm dlx giget gh:fastify/fastify-vite/starters/react-base#dev m-app
pnpm i
npm run dev

Expected Behavior

See the template running

niicojs commented 7 months ago

FYI the exact same steps works on WSL

Shyam-Chen commented 6 months ago

It may be necessary to convert file:///C:/Users/myname/ to file:///C|/Users/myname/.

galvez commented 6 months ago

Hey @Shyam-Chen — an user is reporting this error:

Screen Shot 2024-03-03 at 06 02 38

Can you take a look?

Shyam-Chen commented 6 months ago

The issue occurred at this line.

https://github.com/Shyam-Chen/fastify-vite/blob/dev/packages/fastify-vue/plugin.cjs#L8