<h1 dir="auto">Bug report</h1>
<h2 dir="auto">Describe the bug</h2>
<p dir="auto">An index page implemented within a subdirectory behaves differently between development and production modes.</p>
<p dir="auto">When the next server is started in dev mode everything seems to work as expected. When running in "production" mode via <code class="notranslate">next build</code> and <code class="notranslate">next start</code> the event listeners on page do not fire.</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">I created a minimal example here: <a href="https://github.com/hoffrocket/next8bug">https://github.com/hoffrocket/next8bug</a></p>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">I'd expect the same behavior in production as in dev. The event listeners should fire.</p>
<h2 dir="auto">System information</h2>
<ul dir="auto">
<li>OS: macOS</li>
<li>chrome, safari</li>
<li>Version of Next.js: 8.0.1</li>
<li>Version of node: 8.14.0</li>
</ul>
<h1 dir="auto">Bug report</h1>
<p dir="auto">When you build next.js when the index page is located in <code class="notranslate">/index/index.js</code> instead of <code class="notranslate">/index.js</code> The client side script will not be executed when you access <code class="notranslate">http://localhost/</code>.</p>
<p dir="auto">The built index page will register with <code class="notranslate">/index</code> (as shown below)</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="(window.__NEXT_P = window.__NEXT_P || []).push([&quot;/index&quot;, function () {
  var e = n(&quot;gDgk&quot;);
  return {
    page: e.default || e
  }
}])"><pre class="notranslate"><span class="pl-kos">(</span><span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">__NEXT_P</span> <span class="pl-c1">=</span> <span class="pl-smi">window</span><span class="pl-kos">.</span><span class="pl-c1">__NEXT_P</span> <span class="pl-c1">||</span> <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">push</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-s">"/index"</span><span class="pl-kos">,</span> <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">var</span> <span class="pl-s1">e</span> <span class="pl-c1">=</span> <span class="pl-en">n</span><span class="pl-kos">(</span><span class="pl-s">"gDgk"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">return</span> <span class="pl-kos">{</span>
    <span class="pl-c1">page</span>: <span class="pl-s1">e</span><span class="pl-kos">.</span><span class="pl-c1">default</span> <span class="pl-c1">||</span> <span class="pl-s1">e</span>
  <span class="pl-kos">}</span>
<span class="pl-kos">}</span><span class="pl-kos">]</span><span class="pl-kos">)</span></pre></div>
<p dir="auto">Moving the index.js to the pages root will restore the wanted behaviour.<br>
It took a while for me to figure out what the actual issue is as it's working just fine in dev mode.</p>
<h2 dir="auto">To Reproduce</h2>
<p dir="auto">Steps to reproduce the behavior, please provide code snippets or a repository:</p>
<ol dir="auto">
<li>Check out <a href="https://github.com/adlk/nextjs-index-issue">https://github.com/adlk/nextjs-index-issue</a></li>
<li>Run <code class="notranslate">npm install &amp;&amp; npm run build &amp;&amp; npm start</code></li>
<li>Check in DevTools if you have a log with <code class="notranslate">Home: component did mount</code></li>
</ol>
<h2 dir="auto">System information</h2>
<ul dir="auto">
<li>Version of Next.js: 8.0.0</li>
</ul>