title: FS module doesn't work after packaging in electron
body: <p>I'm trying to learn electron by creating a simple project and it works when I write start it with <code>npm start</code>, but when I package it with the electron packager, the node js part doesn't work anymore.</p>
  <p>This is the main process :</p>
  <pre><code>const { app, BrowserWindow, ipcMain , globalShortcut} = require('electron');
  const fs = require('fs');
  
  let mainWindow;
  
  function createWindow () {
    mainWindow = new BrowserWindow({
      width: 1200,
      height: 600,
      webPreferences: {
        nodeIntegration: true,
        contextIsolation: false
      }
    });
    mainWindow.loadFile('src/index.html');
  
    globalShortcut.register('f5', function() {
          mainWindow.reload()
      })
  };
  
  app.whenReady().then(() =&gt; {
    createWindow()
  
  app.on('activate', () =&gt; {
      if (BrowserWindow.getAllWindows().length === 0) {
        createWindow()
      }
    })
  });
  
  app.on('window-all-closed', () =&gt; {
    if (process.platform !== 'darwin') {
      app.quit()
    }
  });
  
  ipcMain.on(&quot;message&quot;, (event, arg) =&gt; {
      const data = {
        &quot;num&quot;: arg
      };
      fs.writeFile('src/data.json', JSON.stringify(data), () =&gt; {
        event.returnValue = &quot;success&quot;;
      })
  })
  </code></pre>
  <p>and this is the renderer process:</p>
  <pre><code>const {ipcRenderer} = require(&quot;electron&quot;);
  const saveBtn = document.getElementById('saveBtn');
  const inp = document.getElementById('inp');
  const fetchBtn = document.getElementById('fetchBtn');
  
  saveBtn.onclick = () =&gt; {
    if (!inp.value) return alert(&quot;Your input is empty&quot;);
    if (isNaN(inp.value)) return alert(&quot;The input is not a number&quot;);
  
    ipcRenderer.sendSync(&quot;message&quot;, inp.value);
  }
  
  fetchBtn.onclick = () =&gt; {
    fetch(&quot;data.json&quot;)
      .then(res =&gt; res.json())
      .then(res =&gt; console.log(res.num))
  }
  </code></pre>
  <p>This is the package.json file: (ignore the electron-forge things)</p>
  <pre><code>{
    &quot;name&quot;: &quot;electron-project&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;&quot;,
    &quot;main&quot;: &quot;app.js&quot;,
    &quot;build&quot;: {
      &quot;asar&quot;: false
    },
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;electron-forge start&quot;,
      &quot;package&quot;: &quot;electron-forge package&quot;,
      &quot;make&quot;: &quot;electron-forge make&quot;
    },
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;devDependencies&quot;: {
      &quot;@electron-forge/cli&quot;: &quot;^6.0.0-beta.54&quot;,
      &quot;@electron-forge/maker-deb&quot;: &quot;^6.0.0-beta.54&quot;,
      &quot;@electron-forge/maker-rpm&quot;: &quot;^6.0.0-beta.54&quot;,
      &quot;@electron-forge/maker-squirrel&quot;: &quot;^6.0.0-beta.54&quot;,
      &quot;@electron-forge/maker-zip&quot;: &quot;^6.0.0-beta.54&quot;,
      &quot;electron&quot;: &quot;^12.0.2&quot;
    },
    &quot;dependencies&quot;: {
      &quot;electron-squirrel-startup&quot;: &quot;^1.0.0&quot;
    },
    &quot;config&quot;: {
      &quot;forge&quot;: {
        &quot;packagerConfig&quot;: {},
        &quot;makers&quot;: [
          {
            &quot;name&quot;: &quot;@electron-forge/maker-squirrel&quot;,
            &quot;config&quot;: {
              &quot;name&quot;: &quot;electron_project&quot;
            }
          },
          {
            &quot;name&quot;: &quot;@electron-forge/maker-zip&quot;,
            &quot;platforms&quot;: [
              &quot;darwin&quot;
            ]
          },
          {
            &quot;name&quot;: &quot;@electron-forge/maker-deb&quot;,
            &quot;config&quot;: {}
          },
          {
            &quot;name&quot;: &quot;@electron-forge/maker-rpm&quot;,
            &quot;config&quot;: {}
          }
        ]
      }
    }
  }
  </code></pre>
  <p>and the data.json file is just an  object with a <code>num</code> property and a value.</p>
  <p>When I run the program with <code>npm start</code> I can give a value and change the value of the json file, but when I packaged the app with electron packager, it wasn't working.</p>
  <p>Also sorry for the messy code I wrote. I've just started learning to code.</p>