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

dev-scripts path issue on Windows #955

Open
1 task
zaaakher opened this issue Jul 19, 2024 · 5 comments
Open
1 task

dev-scripts path issue on Windows #955

zaaakher opened this issue Jul 19, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@zaaakher
Copy link
Contributor

Describe the bug
Running npm run gen throws the following error on Windows:

image

To Reproduce

  • Be on Windows 10
  • Run npm install
  • Run npm run gen from the root of the project or from examples dir
  • See the same error as the screenshot above

Misc

  • Node version: 18.20.3
  • Package manager: pnpm
  • Browser: Chrome
  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖

I was hitting my head for an hour trying to figure this one out. When I comment out fs.writeFileSync the error is gone, and this seems to be originating from the way we're getting the path/dir :

const dir = path.parse(import.meta.url.replace("file://", "")).dir;

This issue is in every instance of the above code, in gen.ts, genDocs.ts, and util.ts


I was only able to generate the example code in #954 using my MacOS. So this issue is exclusively on Windows.

@zaaakher zaaakher added the bug Something isn't working label Jul 19, 2024
@jkcs
Copy link
Contributor

jkcs commented Jul 19, 2024

need change

import { fileURLToPath } from "url";

const dir = path.parse(fileURLToPath(import.meta.url)).dir;

@zaaakher
Copy link
Contributor Author

zaaakher commented Jul 19, 2024

@jkcs That silenced the error but it doesn't seem to be actually generating the examples.gen.tsx due to getExampleProjects not finding any example files due to it not knowing the exact path

@jkcs
Copy link
Contributor

jkcs commented Jul 22, 2024

@zaaakher
Copy link
Contributor Author

zaaakher commented Jul 22, 2024

try this:https://github.com/TypeCellOS/BlockNote/pull/818/files#diff-93421da21c480705d1154839957c6737a254abe9cc85a0e91f792ce42627e17e

That only silenced the errors. But unfortunately it can't read any example directories which makes it output an empty example object in examples.gen.tsx

@matthewlipski
Copy link
Collaborator

Ah yeah, I was also running into this when I was working on Windows way back. Basically, node:path handles Windows and MacOS paths pretty differently and it's just kind of a pain. Unfortunately the solution that was most convenient for me was removing all path calls and replacing them with hardcoded strings:(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants