I'm building react based desktop pplication with github electron. Electron allow to use node.js features in browser code. However I still need browserify for compile react files.
The issue is that with standard browserify policies node code goes invalid. require no longer work as expected, __filename and __dirname start showing things which is not close to 'on-disk' reality, etc.
Is there is any kind of vision how it's possible to friend electron with browserify?
window.require, window.__filename, and window.__dirname
Try this:
browserify --no-builtins --no-commondir --insert-global-vars="global" app.js
Can I do this from gulpfile? I mean browserify my nodejs application using gulp?
Probably related: https://github.com/substack/node-browserify/issues/481
Uncaught Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
Error thrown when trying this when using browserify+vue on my app.js:
"browserify": "browserify -t vueify browserify --ignore-missing --no-builtins --no-commondir --insert-global-vars=\"global\" --no-browser-field -e app.js -o resources/bundle.js --debug",
@angrykoala I had to add -x electron to my browserify command. I also needed to do the same for -x spellchecker if you're using that module too.
Most helpful comment
Error thrown when trying this when using browserify+vue on my app.js: