unable to use conf inside a webworker
See original GitHub issueHi there,
I’m using conf inside a webworker and experiencing some issues in making it work.
The webworker is initiated from Electron, but has nodeIntegrationInWorker and nodeIntegration at all places so the context there is of NodeJS, not browser ~ electron one.
(When I want to use config file from the main process of electron, Im using electron-store 😃 )
The error Im getting is the following:
After digging a little inside the error, it got me to these lines in conf’s index.js:
as you can see here, the cache deletion is being targeted at the wrong path when using the __filename , probably on runtime this special variable is being translated into this not-so-nice electron path 😞
I also tried to use electron-store (although the webworker has a node context) but it gave this error:

Will be happy to get some advise about it, or if it’s something that needs to be added to this awesome library, I’d be happy to contribute 😎
thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:8 (8 by maintainers)

Top Related StackOverflow Question
Sure
Yeah, we should just remove that logic as it won’t work with ESM anyway.
The problem is that it’s inconvenient for every user to have to find the path to their package.json, load the JSON, parse it, and then get those properties out of it themselves. Maybe we could add a new option called
importMetaat the same time. It could acceptimport.meta. We could then useimport.meta.urlto find the package.json. I’m open to other ideas.