firebolt-dev / firebolt

The Simple React Framework
https://firebolt.dev
MIT License
128 stars 6 forks source link

FIX: modDir pathname. delete first / from pathname #5

Open VanyaMate opened 5 months ago

VanyaMate commented 5 months ago

Hello. I tried to create the application using npm create firebolt@latest but failed due to an error with the paths.

When calling new URL('.', import.meta.url).pathname, I received a path that starts with the "/" character. Because of this, in the future, with path.join, the disk was added to the beginning again. glIw9lT5zoE

If you remove the "/" the error disappears and everything works. p3qjUYAjb0I

VanyaMate commented 5 months ago

Unfortunately, such errors occur in other parts as well. For example, I cannot start the server for the same reason via npm run dev.

VanyaMate commented 5 months ago

Unfortunately, I couldn't quickly figure out what the problem was. The first problem is also related to pathname. dev 1err When I remove this code, the problem goes away, but the next one appears.

The second problem is also related to paths, but it has something to do with absolute paths in Windows, as I understand it. But this is not a fact. 2err reas

I updated both npm and node to the latest versions, the problem remained. I have windows 10.

ashconnell commented 5 months ago

Thanks for digging in and having a look! Are you able to help me out a bit, I don't have access to windows right now:

  1. What is the exact output of import.meta.url for you?
  2. What is the exact output of new URL('.', import.meta.url).pathname
  3. What is the exact output of path.join(modDir, '../package.json')

I just want to check what the discrepancies for these are on windows vs osx, then I should be able to fix it.

There are a few places we rely on import.meta.url in the code base so they will all need to be updated, most likely.

VanyaMate commented 5 months ago

@ashconnell Hi, sorry, I didn't notice the message right away.

Yes, sure. Paths for in packages/create-firebolt/src/index.

import.meta.url: file:///C:/dev/opensource/firebolt/packages/create-firebolt/src/index.js new URL(".", import.meta.url).pathname: /C:/dev/opensource/firebolt/packages/create-firebolt/src/ path.join(modDir, "../package.json"): \C:\dev\opensource\firebolt\packages\create-firebolt\package.json image

And because of the "\" at the beginning of \C:\dev... i get this error where C:\ is added to the beginning again image

but if you remove the "\" the paths become normal and there is no error. image

Similar problems are found in other places. For the same reason I can't start the dev server, for example.