title: How do I include 'fs' modules in Sapper?
body: <p>I am working on a Sapper project, as it seemed neat for a little project I wanted to get up and running quickly. That's not be easy and I'm now having trouble running scripts from my Sapper project that include the built-in 'fs' modules.</p>
  
  <p>I'm trying to build a character generator. I have built a script that will do this but I'd like to be able to save my generated characters as JSON files then read them in later. Reading in is easy, writing doesn't seem to be listed anywhere obvious. The best I have is trying to get the built in plugins to function to allow me access to fs modules but my research on this is spotty and not helping. Trying to get rollup to help doesn't appear to work and I am unable to find an acceptable alternative. </p>
  
  <p>Whenever I run the project, it just says that it can't resolve it. </p>
  
  <p><code>Could not load fs (imported by E:\Software Projects\Javascript\Io-Generator\src\routes\generator\generator.js): ENOENT: no such file or directory, open 'E:\Software Projects\Javascript\Io-Generator\fs'</code></p>
  
  <p>Nothing I do seems to help. Please can someone explain what I'm missing here? Am I using Sapper wrong? Am I missing something in rollup here? Is there an alternative I'm missing?</p>
  
  <p>My roll-up config if it helps:</p>
  
  <pre><code>    client: {
          input: config.client.input(),
          output: config.client.output(),
          plugins: [
              replace({
                  'process.browser': true,
                  'process.env.NODE_ENV': JSON.stringify(mode)
              }),
              svelte({
                  dev,
                  hydratable: true,
                  emitCss: true
              }),
              resolve({
                  browser: true,
                  preferBuiltins: true,
                  dedupe
              }),
              commonjs( {
                  browser: true
              } ),
  
              globals(),
  
              builtins( {
                  fs: true
              } ),
  
              json(),
  
              legacy &amp;&amp; babel({
                  extensions: ['.js', '.mjs', '.html', '.svelte'],
                  runtimeHelpers: true,
                  exclude: ['node_modules/@babel/**'],
                  presets: [
                      ['@babel/preset-env', {
                          targets: '&gt; 0.25%, not dead'
                      }]
                  ],
                  plugins: [
                      '@babel/plugin-syntax-dynamic-import',
                      ['@babel/plugin-transform-runtime', {
                          useESModules: true
                      }]
                  ]
              }),
  
              !dev &amp;&amp; terser({
                  module: true
              })
          ],
  
          onwarn,
      },
  
      server: {
          input: config.server.input(),
          output: config.server.output(),
          plugins: [
              replace({
                  'process.browser': false,
                  'process.env.NODE_ENV': JSON.stringify(mode)
              }),
              svelte({
                  generate: 'ssr',
                  dev
              }),
              resolve({
                  browser: false,
                  preferBuiltins: true,
                  dedupe
              }),
              commonjs(),
              builtins( {
                  fs: true
              } ),
              json()
          ],
          external: Object.keys(pkg.dependencies).concat(
              require('module').builtinModules || Object.keys(process.binding('natives'))
          ),
  
          onwarn,
      },
  
      serviceworker: {
          input: config.serviceworker.input(),
          output: config.serviceworker.output(),
          plugins: [
              resolve( {
                  browser: false,
                  preferBuiltins: true
              } ),
              replace({
                  'process.browser': true,
                  'process.env.NODE_ENV': JSON.stringify(mode)
              }),
              commonjs(),
              builtins( {
                  fs: true
              } ),
              json(),
              !dev &amp;&amp; terser()
          ],
  
          onwarn,
      }
  };```
  </code></pre>