<p dir="auto">I'm trying to run the latest version of Next (4.3-canary1 since it fixes an issue with <code class="notranslate">babel-runtime</code>) in AWS Lambda using <code class="notranslate">claudia</code> for packaging and <code class="notranslate">express</code> combined with <code class="notranslate">aws-serverless-express</code>.</p>
<p dir="auto">Once the package deployed, I'm getting an error when querying the proxy API, ex.<br>
<code class="notranslate">https://xxxxx.execute-api.eu-west-1.amazonaws.com/latest/</code></p>
<p dir="auto">Next drops <code class="notranslate">Internal Server Error</code> and in the logs I get the following:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{ Error: Cannot find module /var/task/.next/dist/bundles/pages/_error
at _callee$ (/var/task/node_modules/next/dist/server/resolve.js:220:19)
at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:62:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:296:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/var/task/node_modules/regenerator-runtime/runtime.js:114:21)
at step (/var/task/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /var/task/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13 code: 'ENOENT' }"><pre class="notranslate"><code class="notranslate">{ Error: Cannot find module /var/task/.next/dist/bundles/pages/_error
at _callee$ (/var/task/node_modules/next/dist/server/resolve.js:220:19)
at tryCatch (/var/task/node_modules/regenerator-runtime/runtime.js:62:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/var/task/node_modules/regenerator-runtime/runtime.js:296:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/var/task/node_modules/regenerator-runtime/runtime.js:114:21)
at step (/var/task/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /var/task/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13 code: 'ENOENT' }
</code></pre></div>
<p dir="auto">I pushed a simple project to reproduce that issue easily: <a href="https://github.com/jgautheron/next-serverless">https://github.com/jgautheron/next-serverless</a>.</p>
<p dir="auto"><strong>EDIT</strong>: it seems that this issue is tightly linked to 4.3, it works if I use the 4.2 and make sure that <code class="notranslate">next/node_modules/babel-runtime</code> exists.</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"><code class="notranslate">next build</code> does not include absolute path to node module</p>
<h2 dir="auto">Current Behavior</h2>


<p dir="auto"><code class="notranslate">next build</code> includes absolute path in transpiled require path</p>
<h2 dir="auto">Steps to Reproduce (for bugs)</h2>
<h3 dir="auto">Correct</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="yarn add next@4.2.0
next build

# Transpiled output
var _extends2 = require('babel-runtime/helpers/extends');"><pre class="notranslate">yarn add next@4.2.0
next build

<span class="pl-c"><span class="pl-c">#</span> Transpiled output</span>
var _extends2 = require(<span class="pl-s"><span class="pl-pds">'</span>babel-runtime/helpers/extends<span class="pl-pds">'</span></span>)<span class="pl-k">;</span></pre></div>
<h3 dir="auto">Incorrect</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="yarn add next@canary
next build

# Transpiled output
var _extends2 = require('/Users/kyle/projects/test/node_modules/babel-runtime/helpers/extends');"><pre class="notranslate">yarn add next@canary
next build

<span class="pl-c"><span class="pl-c">#</span> Transpiled output</span>
var _extends2 = require(<span class="pl-s"><span class="pl-pds">'</span>/Users/kyle/projects/test/node_modules/babel-runtime/helpers/extends<span class="pl-pds">'</span></span>)<span class="pl-k">;</span></pre></div>
<h2 dir="auto">Context</h2>


<p dir="auto">Unable to deploy to lambda using <a href="https://github.com/apex/up">up</a> due to <code class="notranslate">up</code> building locally and uploading zip file to s3 rendering absolute paths invalid</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>canary</td>
</tr>
<tr>
<td>node</td>
<td>8.9.0</td>
</tr>
<tr>
<td>OS</td>
<td>macos 10.13.2</td>
</tr>
</tbody>
</table>