title: Update to Angular v6 - Module not found: Error: Can't resolve 'fs'
body: <p>I'm trying to migrate my Angular Universal project from Angular v5 to v6</p>
  
  <p>I've got a service where I use <code>fs</code> to load the translation on the server side. Everything works well with Angular v5.</p>
  
  <p>With Angular v6, when I run <code>npm run start</code> aka <code>ng serve --proxy-config proxy.conf.json</code> I face the following error</p>
  
  <blockquote>
    <p>ERROR in
    ./src/providers/core/translate/translate-universal-loader.service.ts
    Module not found: Error: Can't resolve 'fs' in
    '/Users/me/Documents/projects/myproject/src/providers/core/translate'</p>
  </blockquote>
  
  <p>In my service I declare <code>fs</code> like the following:</p>
  
  <pre><code>declare var require: any;
  const fs = require('fs');
  </code></pre>
  
  <p>I also tried to declare it like following, but didn't help</p>
  
  <pre><code>import * as fs from 'fs';
  </code></pre>
  
  <p>To tell webpack to ignore fs I tried to add the following in my <code>webpack.server.config.js</code> without success</p>
  
  <pre><code>node: {
      fs: 'empty'
  }
  </code></pre>
  
  <p>also tried with a webpack plugin, wasn't successful neither</p>
  
  <pre><code>new webpack.IgnorePlugin(/fs/)
  </code></pre>
  
  <p>but actually it's maybe not the config use by <code>ng serve</code> but I don't know if I could still eject the configuration with v6?</p>
  
  <p>anyone has got an idea?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>If I declare fs as <code>any</code> it solves the problem for <code>ng serve</code> but unfortunately it will not work on the server side after <code>npm run build:ssr</code> and run <code>npm run serve</code>. On the server side I will then face the following error</p>
  
  <blockquote>
    <p>ERROR ReferenceError: fs is not defined</p>
  </blockquote>
  
  <p>p.s.: my project follows <a href="https://github.com/angular/universal-starter" rel="noreferrer">https://github.com/angular/universal-starter</a> structure, config and dependencies</p>