title: Error: ENOENT: no such file or directory, open 'dist\browser\index.html'
body: <p>Whenever I run <code>ng deploy --preview</code>, I get the error:</p>
  <pre><code>Error: ENOENT: no such file or directory, open 'dist\index.html'
      at Object.openSync (fs.js:457:3)
      at readFileSync (fs.js:359:35)
  </code></pre>
  <p>I've tried following multiple tutorials on the web, but couldn't solve the error. I've tried to access <code>dist/browser/index.html</code> instead with no success.</p>
  <h2>server.ts</h2>
  <pre><code>(global as any).WebSocket = require('ws');
  (global as any).XMLHttpRequest = require('xhr2');
  
  import 'zone.js/dist/zone-node';
  
  import { ngExpressEngine } from '@nguniversal/express-engine';
  import * as express from 'express';
  import { join } from 'path';
  
  import { AppServerModule } from './src/main.server';
  import { APP_BASE_HREF } from '@angular/common';
  import { existsSync, readFileSync } from 'fs';
  
  const path = require('path');
  const domino = require('domino');
  const template = readFileSync(path.join('.', 'dist', 'index.html')).toString();
  const win = domino.createWindow(template);
  
  global['window'] = win;
  global['document'] = win.document;
  
  // The Express app is exported so that it can be used by serverless Functions.
  export function app(): express.Express {
    const server = express();
    const distFolder = join(process.cwd(), 'dist/iquench-website/browser');
    const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index';
  
    // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
    server.engine('html', ngExpressEngine({
      bootstrap: AppServerModule,
    }));
  
    server.set('view engine', 'html');
    server.set('views', distFolder);
  
    // Example Express Rest API endpoints
    // server.get('/api/**', (req, res) =&gt; { });
    // Serve static files from /browser
    server.get('*.*', express.static(distFolder, {
      maxAge: '1y'
    }));
  
    // All regular routes use the Universal engine
    server.get('*', (req, res) =&gt; {
      res.render(indexHtml, { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
      // res.render(indexHtml, { req, res });
    });
  
    return server;
  }
  
  function run(): void {
    const port = process.env.PORT || 4000;
  
    // Start up the Node server
    const server = app();
    server.listen(port, () =&gt; {
      console.log(`Node Express server listening on http://localhost:${port}`);
    });
  }
  
  // Webpack will replace 'require' with '__webpack_require__'
  // '__non_webpack_require__' is a proxy to Node 'require'
  // The below code is to ensure that the server is run only when not requiring the bundle.
  declare const __non_webpack_require__: NodeRequire;
  const mainModule = __non_webpack_require__.main;
  const moduleFilename = mainModule &amp;&amp; mainModule.filename || '';
  if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
    run();
  }
  
  export * from './src/main.server';
  </code></pre>
  <h2>angular.json</h2>
  <pre><code>{
    &quot;$schema&quot;: &quot;./node_modules/@angular/cli/lib/config/schema.json&quot;,
    &quot;version&quot;: 1,
    &quot;newProjectRoot&quot;: &quot;projects&quot;,
    &quot;projects&quot;: {
      &quot;iquench-website&quot;: {
        &quot;projectType&quot;: &quot;application&quot;,
        &quot;schematics&quot;: {
          &quot;@schematics/angular:component&quot;: {
            &quot;style&quot;: &quot;scss&quot;
          },
          &quot;@schematics/angular:application&quot;: {
            &quot;strict&quot;: true
          }
        },
        &quot;root&quot;: &quot;&quot;,
        &quot;sourceRoot&quot;: &quot;src&quot;,
        &quot;prefix&quot;: &quot;app&quot;,
        &quot;architect&quot;: {
          &quot;build&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:browser&quot;,
            &quot;options&quot;: {
              &quot;outputPath&quot;: &quot;dist/browser&quot;,
              &quot;index&quot;: &quot;src/index.html&quot;,
              &quot;main&quot;: &quot;src/main.ts&quot;,
              &quot;polyfills&quot;: &quot;src/polyfills.ts&quot;,
              &quot;tsConfig&quot;: &quot;tsconfig.app.json&quot;,
              &quot;aot&quot;: true,
              &quot;assets&quot;: [
                &quot;src/favicon.ico&quot;,
                &quot;src/assets&quot;,
                &quot;src/manifest.webmanifest&quot;
              ],
              &quot;styles&quot;: [
                &quot;src/styles/styles.scss&quot;,
                &quot;src/styles/variables.scss&quot;,
                &quot;src/styles/theme.scss&quot;,
                &quot;src/styles/form-styles.scss&quot;
              ],
              &quot;scripts&quot;: []
            },
            &quot;configurations&quot;: {
              &quot;production&quot;: {
                &quot;fileReplacements&quot;: [
                  {
                    &quot;replace&quot;: &quot;src/environments/environment.ts&quot;,
                    &quot;with&quot;: &quot;src/environments/environment.prod.ts&quot;
                  }
                ],
                &quot;optimization&quot;: true,
                &quot;outputHashing&quot;: &quot;all&quot;,
                &quot;sourceMap&quot;: false,
                &quot;namedChunks&quot;: false,
                &quot;extractLicenses&quot;: true,
                &quot;vendorChunk&quot;: false,
                &quot;buildOptimizer&quot;: true,
                &quot;budgets&quot;: [
                  {
                    &quot;type&quot;: &quot;initial&quot;,
                    &quot;maximumWarning&quot;: &quot;2mb&quot;,
                    &quot;maximumError&quot;: &quot;5mb&quot;
                  },
                  {
                    &quot;type&quot;: &quot;anyComponentStyle&quot;,
                    &quot;maximumWarning&quot;: &quot;2kb&quot;,
                    &quot;maximumError&quot;: &quot;4kb&quot;
                  }
                ],
                &quot;serviceWorker&quot;: true,
                &quot;ngswConfigPath&quot;: &quot;ngsw-config.json&quot;
              }
            }
          },
          &quot;serve&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:dev-server&quot;,
            &quot;options&quot;: {
              &quot;browserTarget&quot;: &quot;iquench-website:build&quot;
            },
            &quot;configurations&quot;: {
              &quot;production&quot;: {
                &quot;browserTarget&quot;: &quot;iquench-website:build:production&quot;
              }
            }
          },
          &quot;extract-i18n&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:extract-i18n&quot;,
            &quot;options&quot;: {
              &quot;browserTarget&quot;: &quot;iquench-website:build&quot;
            }
          },
          &quot;test&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:karma&quot;,
            &quot;options&quot;: {
              &quot;main&quot;: &quot;src/test.ts&quot;,
              &quot;polyfills&quot;: &quot;src/polyfills.ts&quot;,
              &quot;tsConfig&quot;: &quot;tsconfig.spec.json&quot;,
              &quot;karmaConfig&quot;: &quot;karma.conf.js&quot;,
              &quot;assets&quot;: [
                &quot;src/favicon.ico&quot;,
                &quot;src/assets&quot;,
                &quot;src/manifest.webmanifest&quot;
              ],
              &quot;styles&quot;: [
                &quot;src/styles.scss&quot;
              ],
              &quot;scripts&quot;: []
            }
          },
          &quot;lint&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:tslint&quot;,
            &quot;options&quot;: {
              &quot;tsConfig&quot;: [
                &quot;tsconfig.app.json&quot;,
                &quot;tsconfig.spec.json&quot;,
                &quot;e2e/tsconfig.json&quot;,
                &quot;tsconfig.server.json&quot;
              ],
              &quot;exclude&quot;: [
                &quot;**/node_modules/**&quot;
              ]
            }
          },
          &quot;e2e&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:protractor&quot;,
            &quot;options&quot;: {
              &quot;protractorConfig&quot;: &quot;e2e/protractor.conf.js&quot;,
              &quot;devServerTarget&quot;: &quot;iquench-website:serve&quot;
            },
            &quot;configurations&quot;: {
              &quot;production&quot;: {
                &quot;devServerTarget&quot;: &quot;iquench-website:serve:production&quot;
              }
            }
          },
          &quot;deploy&quot;: {
            &quot;builder&quot;: &quot;@angular/fire:deploy&quot;,
            &quot;options&quot;: {
              &quot;ssr&quot;: true
            }
          },
          &quot;server&quot;: {
            &quot;builder&quot;: &quot;@angular-devkit/build-angular:server&quot;,
            &quot;options&quot;: {
              &quot;outputPath&quot;: &quot;dist/server&quot;,
              &quot;main&quot;: &quot;server.ts&quot;,
              &quot;tsConfig&quot;: &quot;tsconfig.server.json&quot;,
              &quot;externalDependencies&quot;: [
                &quot;firebase&quot;,
                &quot;@firebase/app&quot;,
                &quot;@firebase/analytics&quot;,
                &quot;@firebase/auth&quot;,
                &quot;@firebase/component&quot;,
                &quot;@firebase/database&quot;,
                &quot;@firebase/firestore&quot;,
                &quot;@firebase/functions&quot;,
                &quot;@firebase/installations&quot;,
                &quot;@firebase/messaging&quot;,
                &quot;@firebase/storage&quot;,
                &quot;@firebase/performance&quot;,
                &quot;@firebase/remote-config&quot;,
                &quot;@firebase/util&quot;
              ]
            },
            &quot;configurations&quot;: {
              &quot;production&quot;: {
                &quot;outputHashing&quot;: &quot;media&quot;,
                &quot;fileReplacements&quot;: [
                  {
                    &quot;replace&quot;: &quot;src/environments/environment.ts&quot;,
                    &quot;with&quot;: &quot;src/environments/environment.prod.ts&quot;
                  }
                ],
                &quot;sourceMap&quot;: false,
                &quot;optimization&quot;: true
              }
            }
          },
          &quot;serve-ssr&quot;: {
            &quot;builder&quot;: &quot;@nguniversal/builders:ssr-dev-server&quot;,
            &quot;options&quot;: {
              &quot;browserTarget&quot;: &quot;iquench-website:build&quot;,
              &quot;serverTarget&quot;: &quot;iquench-website:server&quot;
            },
            &quot;configurations&quot;: {
              &quot;production&quot;: {
                &quot;browserTarget&quot;: &quot;iquench-website:build:production&quot;,
                &quot;serverTarget&quot;: &quot;iquench-website:server:production&quot;
              }
            }
          },
          &quot;prerender&quot;: {
            &quot;builder&quot;: &quot;@nguniversal/builders:prerender&quot;,
            &quot;options&quot;: {
              &quot;browserTarget&quot;: &quot;iquench-website:build:production&quot;,
              &quot;serverTarget&quot;: &quot;iquench-website:server:production&quot;,
              &quot;routes&quot;: [
                &quot;/&quot;
              ]
            },
            &quot;configurations&quot;: {
              &quot;production&quot;: {}
            }
          }
        }
      }
    },
    &quot;defaultProject&quot;: &quot;iquench-website&quot;
  }
  </code></pre>
  <h2>firebase.json</h2>
  <pre><code>{
    &quot;hosting&quot;: [
      {
        &quot;target&quot;: &quot;iquench-website&quot;,
        &quot;public&quot;: &quot;dist\\iquench-website\\dist\\browser&quot;,
        &quot;ignore&quot;: [
          &quot;**/.*&quot;
        ],
        &quot;headers&quot;: [
          {
            &quot;source&quot;: &quot;*.[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f].+(css|js)&quot;,
            &quot;headers&quot;: [
              {
                &quot;key&quot;: &quot;Cache-Control&quot;,
                &quot;value&quot;: &quot;public,max-age=31536000,immutable&quot;
              }
            ]
          }
        ],
        &quot;rewrites&quot;: [
          {
            &quot;source&quot;: &quot;**&quot;,
            &quot;function&quot;: &quot;ssr&quot;
          }
        ]
      }
    ],
    &quot;functions&quot;: {
      &quot;source&quot;: &quot;dist&quot;
    }
  }
  </code></pre>
  <p>I'm pretty new to Angular Universal and SSR, so please let me know if I'm doing something wrong. Thanks in advance!</p>