pjeby / hot-reload

Automatically reload Obsidian plugins in development when their files are changed
ISC License
512 stars 24 forks source link

FIX | `require('fs')` (so, this plugin) breaks on latest Node version #16

Open ChasKane opened 1 month ago

ChasKane commented 1 month ago

After upgrading to latest node version (v20.16.0), I started seeing the below error in the console and noticed that hot reload wasn't working anymore (changes to other plugins' main.js files didn't work). I'm not sure what change in node made this happen, but adding window. before require("fs") fixed it for me. Leaving the this and the reference in case this is helpful for anyone else. As I'm unsure if this is a shared issue, I'll abstain from making a fork and PR for now.

Error: [hot-reload] Attempting to load NodeJS package: "fs"

pjeby commented 1 month ago

I don't understand how your node upgrade could remotely be relevant, since Obsidian is in Electron and neither it nor hot-reload use your local node installation in any fashion. Did you recently upgrade Obsidian, perhaps? Especially an upgrade via the installer?

pjeby commented 3 weeks ago

Actually, given the PR, does that mean that this issue was you trying to use the plugin on mobile? If so, please go ahead and close this.