title: index.js not found in React application using Express (Node.js)
body: <p>I am trying to use my own express server for the production of a React app, but I am getting a 404 status of not found for my <code>index.js</code> which have the React js script.</p>
  
  <p>The folder structure that I am using is the following</p>
  
  <pre><code>server.js
  +public
  | index.html
  |
  __+ src
     |
     __ index.js
  </code></pre>
  
  <p>(index.html is in the public folder, index.js is in the src folder)</p>
  
  <p>So In my <code>server.js</code> I have :</p>
  
  <pre><code>// Built-in Node.js modules
  let fs = require('fs');
  let path = require('path');
  
  // Third-party Node.js modules
  let express = require('express');
  
  
  // Express App
  let public_dir = path.join(__dirname, 'public');
  
  // let port = 80; // production port
  let port = 8000; // test/debug port
  
  let app = express();
  app.use(express.static(public_dir));
  
  app.listen(port, () =&gt; {
      console.log("Now listening on port " + port);
  });
  </code></pre>
  
  <p>and in my <code>index.html</code> I am calling in my head tag:</p>
  
  <pre><code>&lt;script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin&gt;&lt;/script&gt;
  &lt;script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin&gt;&lt;/script&gt;
  &lt;script src="./src/index.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>At the end, when I run the server.js I am getting the following error:</p>
  
  <pre><code>Failed to load resource: the server responded with a status of 404 (Not Found)
  </code></pre>
  
  <p>In case you might need this is my index.js</p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import './index.css';
  import App from './App';
  import * as serviceWorker from './serviceWorker';
  
  ReactDOM.render(
    &lt;React.StrictMode&gt;
  
      &lt;App /&gt;
  
    &lt;/React.StrictMode&gt;,
    document.getElementById('root')
  );
  
  // If you want your app to work offline and load faster, you can change
  // unregister() to register() below. Note this comes with some pitfalls.
  serviceWorker.unregister();
  </code></pre>
  
  <p>Thank you!</p>