Closed dave-cross closed 5 months ago
After a little looking, it seems like Electron does not allow access to navigator from within the main process. Have you tried?:
navigator
variable in the main process so see if you can get inquirer to init.Interesting. I know they try to keep it locked down for security, but didn't realize it was that tight.
Tried mocking navigator when I first discovered the bug, but it wasn't working either. Maybe they don't allow attaching to a global object. More likely that I set up it up wrong.
I did try a child process this morning after my opening post. That works. Not the buttery smooth workflow I was hoping for, but that's not Plop's fault.
Closing as this solution works and the heart of the issue isn't with Plop. Thank you for the explanation.
Hi,
I'm trying to create a UI that sits on top of Plop, but I've run into a snag. When I try to use node-plop (even just console.logging the import), it throughs errors.
This is in the main process of an electron app, created with electron-forge (Vite-typescript).
Error is
ReferenceError: navigator is not defined
. Shows up even when above function isn't being called. Seems electron is trying to precompile the code. Reviewing the build file shows that it's looking fornavigator.userAgent
, which seems to be part of Chalk's "supports-color" check, which is used by inquirer.I've tried every flag or global variable I could find (ie.
FORCE_COLOR=0
didn't work). I was able to test the above code with Node directly and it works, just something about electron and thisnavigator not defined
issue.My question is this: since I will display a UI for the prompts and send them directly to node-plop with
runActions
, is there a way to disable/bypass/circumvent this?