Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

VanyaMate
Copy link

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
Copy link
Author

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
Copy link
Author

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
Copy link
Contributor

ashconnell commented Apr 4, 2024

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
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants