I am using the Vue CLI Electron Plugin.
When I start using chokidar (latest version) anywhere in the app and try building the application, I get the following error:
error in ./node_modules/fsevents/fsevents.node
Module parse failed: Unexpected character '�' (1:0)
I have been trying to extend the webpack configuration, but I just cannot get it to work.
Any help is appreciated.
webpack wants to load fsevents binary. Obviously This is incorrect and should not be done.
Look at this docs https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/guide.html#native-modules
and declare chokidar as external module, then everything should work.
// vue.config.js
module.exports = {
pluginOptions: {
electronBuilder: {
// List native deps here if they don't work
externals: ['chokidar'],
// If you are using Yarn Workspaces, you may have multiple node_modules folders
// List them all here so that VCP Electron Builder can find them
nodeModulesPath: ['../../node_modules', './node_modules']
}
}
}
Thank you so much. I feel stupid. I tried everything, also the solution above, but unfortunately not with chokidar but fsevents directly. Wasted way too much time on this.
Your snippet works like a charm. Thanks for the help! 🍻
Most helpful comment
Look at this docs https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/guide.html#native-modules
and declare chokidar as external module, then everything should work.