How to use Native Node Modules on a React, ES6, Electron App?
<p>I have a React, Electron app that I wish to be able to access native node modules from the ES6 compiled (using Babel and Webpack).</p>

<p>For example, when I try to require the "fs" node module to access the filesystem I get the following error.</p>

<pre><code>ERROR in ./src/app.js Module not found: Error: Cannot resolve module 'fs' in C:\Users\Propietario-1\Documents\GitHub\AMPLI @ ./src/app.js 1:358-371
</code></pre>

<p>But when I required this from a "none compiled" js file it works. I can access the "fs" module.</p>

<p>Any help is appreciated.</p>

<p><strong>Update (2016-08-28):</strong> </p>

<p>I ended up requiring the <code>fs</code> module in a script tag on the index.html that calls the bundled script. It works!</p>

<pre><code>&lt;script&gt;
const fs = require('fs');

require('bundle.js');
&lt;/script&gt;
</code></pre>

<p>After doing this the <code>fs</code> becomes a global variable available to all scripts in the <code>bundle.js</code>. Just make sure to edit your linter options to avoid overwriting it or <code>undef</code> errors.</p>