BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

dev-scripts path issue on Windows

Open zaaakher opened this issue 1 year ago • 8 comments

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 avatar Jul 19 '24 07:07 zaaakher

need change

import { fileURLToPath } from "url";

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

jkcs avatar Jul 19 '24 10:07 jkcs

@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

zaaakher avatar Jul 19 '24 13:07 zaaakher

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

jkcs avatar Jul 22 '24 02:07 jkcs

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

zaaakher avatar Jul 22 '24 05:07 zaaakher

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:(

matthewlipski avatar Jul 22 '24 18:07 matthewlipski

/bounty 10

YousefED avatar Jul 29 '24 12:07 YousefED

💎 $10 bounty • BlockNote

Steps to solve:

  1. Start working: Comment /attempt #955 with your implementation plan
  2. Submit work: Create a pull request including /claim #955 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to TypeCellOS/BlockNote!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🔴 @rogueloop Jul 29, 2024, 10:26:48 PM WIP
🟢 @jkcs #970

algora-pbc[bot] avatar Jul 29 '24 12:07 algora-pbc[bot]

/attempt #955

Algora profile Completed bounties Tech Active attempts Options
@rogueloop 1 bounty from 1 project
Java, Go,
Python & more
Cancel attempt

rogueloop avatar Jul 29 '24 22:07 rogueloop

💡 @jkcs submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] avatar Jul 30 '24 02:07 algora-pbc[bot]

@jkcs: You've been awarded a $10 bounty by BlockNote! We'll notify you once it is processed.

algora-pbc[bot] avatar Aug 06 '24 09:08 algora-pbc[bot]

🎉🎈 @jkcs has been awarded $10! 🎈🎊

algora-pbc[bot] avatar Aug 31 '24 23:08 algora-pbc[bot]