<p dir="auto">The using-nerv example is not working</p>


<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/zeit/next.js/issues">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>
<p dir="auto">can start the example server</p>
<h2 dir="auto">Current Behavior</h2>
<p dir="auto">Getting error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt; using-nerv@1.0.0 start /Users/preuss/next.js/examples/using-nerv
&gt; NODE_ENV=production node server.js

module.js:557
    throw err;
    ^

Error: Cannot find module 'nervjs/server'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._resolveFilename (/Users/preuss/next.js/examples/using-nerv/node_modules/module-alias/index.js:43:29)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)"><pre class="notranslate"><code class="notranslate">&gt; using-nerv@1.0.0 start /Users/preuss/next.js/examples/using-nerv
&gt; NODE_ENV=production node server.js

module.js:557
    throw err;
    ^

Error: Cannot find module 'nervjs/server'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._resolveFilename (/Users/preuss/next.js/examples/using-nerv/node_modules/module-alias/index.js:43:29)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
</code></pre></div>
<h2 dir="auto">Steps to Reproduce (for bugs)</h2>
<ol dir="auto">
<li>cd examples/using-nerv</li>
<li>npm i</li>
<li>npm run build &amp;&amp; npm run start</li>
</ol>
<h2 dir="auto">Your Environment</h2>

<table role="table">
<thead>
<tr>
<th>Tech</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>next</td>
<td>latest (5.0.0)</td>
</tr>
<tr>
<td>node</td>
<td>9.4.0</td>
</tr>
<tr>
<td>OS</td>
<td>osx</td>
</tr>
</tbody>
</table>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have searched the <a href="https://github.com/zeit/next.js/issues?q=is%3Aissue">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>
<h2 dir="auto">Expected Behavior</h2>
<p dir="auto">I am proxyfying requests handled by my Express app to my Next.js app, which is used programatically.</p>
<p dir="auto">I have express running on :3000 and next.js on :3001</p>
<p dir="auto">I get <code class="notranslate">TypeError: Cannot read property 'waitUntilReloaded' of undefined at HotReloader._callee7$ (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/hot-reloader.js:658:44)</code> error message when loading any page.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const nextAppConfig = {
  dev: !isHostedOnAWS() &amp;&amp; process.env.NODE_ENV === 'development',
};
const nextApp = next(nextAppConfig);

const nextProxy = nextApp.getRequestHandler(); // Requests handled by nextProxy will be handled by the Next.js app

  app.get('*', (req, res) =&gt; {
    console.log('req from', req.protocol + '://' + req.get('host') + req.originalUrl);
    nextProxy(req, res);
  });"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">nextAppConfig</span> <span class="pl-c1">=</span> <span class="pl-kos">{</span>
  <span class="pl-c1">dev</span>: <span class="pl-c1">!</span><span class="pl-en">isHostedOnAWS</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-s1">process</span><span class="pl-kos">.</span><span class="pl-c1">env</span><span class="pl-kos">.</span><span class="pl-c1">NODE_ENV</span> <span class="pl-c1">===</span> <span class="pl-s">'development'</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">nextApp</span> <span class="pl-c1">=</span> <span class="pl-en">next</span><span class="pl-kos">(</span><span class="pl-s1">nextAppConfig</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">const</span> <span class="pl-s1">nextProxy</span> <span class="pl-c1">=</span> <span class="pl-s1">nextApp</span><span class="pl-kos">.</span><span class="pl-en">getRequestHandler</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// Requests handled by nextProxy will be handled by the Next.js app</span>

  <span class="pl-s1">app</span><span class="pl-kos">.</span><span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s">'*'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-s1">req</span><span class="pl-kos">,</span> <span class="pl-s1">res</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">'req from'</span><span class="pl-kos">,</span> <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-c1">protocol</span> <span class="pl-c1">+</span> <span class="pl-s">'://'</span> <span class="pl-c1">+</span> <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-en">get</span><span class="pl-kos">(</span><span class="pl-s">'host'</span><span class="pl-kos">)</span> <span class="pl-c1">+</span> <span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-c1">originalUrl</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">nextProxy</span><span class="pl-kos">(</span><span class="pl-s1">req</span><span class="pl-kos">,</span> <span class="pl-s1">res</span><span class="pl-kos">)</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">I don't reproduce this issue when running my app on AWS. See <a href="https://swn.dev.vadorequest.fr" rel="nofollow">https://swn.dev.vadorequest.fr</a></p>
<details>
<p dir="auto">sls TypeError: Cannot read property 'waitUntilReloaded' of undefined<br>
sls     at HotReloader._callee7$ (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/hot-reloader.js:658:44)<br>
sls     at tryCatch (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:62:40)<br>
sls     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:296:22)<br>
sls     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:114:21)<br>
sls     at step (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)<br>
sls     at /Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14<br>
sls     at Promise.F (/Users/vadorequest/dev/serverless-with-next/node_modules/core-js/library/modules/_export.js:35:28)<br>
sls     at HotReloader. (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)<br>
sls     at HotReloader.getCompilationErrors (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/hot-reloader.js:837:23)<br>
sls     at Server._callee25$ (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/index.js:1322:41)<br>
sls     at tryCatch (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:62:40)<br>
sls     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:296:22)<br>
sls     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:114:21)<br>
sls     at step (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)<br>
sls     at /Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14<br>
sls     at Promise.F (/Users/vadorequest/dev/serverless-with-next/node_modules/core-js/library/modules/_export.js:35:28)<br>
sls     at Server. (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)<br>
sls     at Server.getCompilationError (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/index.js:1346:23)<br>
sls     at Server._callee20$ (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/index.js:1040:29)<br>
sls     at tryCatch (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:62:40)<br>
sls     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:296:22)<br>
sls     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:114:21)<br>
sls     at step (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)<br>
sls     at /Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14<br>
sls     at Promise.F (/Users/vadorequest/dev/serverless-with-next/node_modules/core-js/library/modules/_export.js:35:28)<br>
sls     at Server. (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)<br>
sls     at Server.renderToHTML (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/index.js:1088:23)<br>
sls     at Server._callee19$ (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/index.js:992:29)<br>
sls     at tryCatch (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:62:40)<br>
sls     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:296:22)<br>
sls     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:114:21)<br>
sls     at step (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)<br>
sls     at /Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14<br>
sls     at Promise.F (/Users/vadorequest/dev/serverless-with-next/node_modules/core-js/library/modules/_export.js:35:28)<br>
sls     at Server. (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)<br>
sls     at Server.render (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/index.js:1020:23)<br>
sls     at Server._callee16$ (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/index.js:817:35)<br>
sls     at tryCatch (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:62:40)<br>
sls     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:296:22)<br>
sls     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:114:21)<br>
sls     at step (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)<br>
sls     at /Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14<br>
sls     at Promise.F (/Users/vadorequest/dev/serverless-with-next/node_modules/core-js/library/modules/_export.js:35:28)<br>
sls     at Object. (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)<br>
sls     at Object.fn (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/index.js:828:27)<br>
sls     at Router._callee$ (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/router.js:81:60)<br>
sls     at tryCatch (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:62:40)<br>
sls     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:296:22)<br>
sls     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:114:21)<br>
sls     at step (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)<br>
sls     at /Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14<br>
sls     at Promise.F (/Users/vadorequest/dev/serverless-with-next/node_modules/core-js/library/modules/_export.js:35:28)<br>
sls     at /Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12<br>
sls     at v (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/router.js:92:29)<br>
sls     at Server._callee18$ (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/index.js:926:24)<br>
sls     at tryCatch (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:62:40)<br>
sls     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:296:22)<br>
sls     at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/vadorequest/dev/serverless-with-next/node_modules/regenerator-runtime/runtime.js:114:21)<br>
sls     at step (/Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)<br>
sls     at /Users/vadorequest/dev/serverless-with-next/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13<br>
sls     at process._tickDomainCallback (internal/process/next_tick.js:135:7)</p>
</details>
<h2 dir="auto">Steps to Reproduce (for bugs)</h2>
<p dir="auto">I've made a specific branch to reproduce this issue at:<br>
<a href="https://github.com/Vadorequest/serverless-with-next/tree/waitUntilReloaded">https://github.com/Vadorequest/serverless-with-next/tree/waitUntilReloaded</a></p>
<h2 dir="auto">Context</h2>
<p dir="auto">I first made it work against AWS and then ran into trouble with a local setup. The main difference between both environment is the <code class="notranslate">dev</code> which is false on AWS.</p>
<p dir="auto">On local env, I run Next.js as a standalone project to get HMR and automatic rebuilds to work.</p>
<h2 dir="auto">Your Environment</h2>

<table role="table">
<thead>
<tr>
<th>Tech</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>next</td>
<td>5.0.1-canary.9</td>
</tr>
<tr>
<td>node</td>
<td>6.10.3</td>
</tr>
</tbody>
</table>