<p dir="auto">npm run build -&gt; (next build) is working locally but on the production web server with the same code it gives the following error log:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="0 info it worked if it ends with ok
1 verbose cli [ '/root/.nvm/versions/node/v8.6.0/bin/node',
1 verbose cli   '/root/.nvm/versions/node/v8.6.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@5.4.2
3 info using node@v8.6.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle frontend@1.0.0~prebuild: frontend@1.0.0
6 info lifecycle frontend@1.0.0~build: frontend@1.0.0
7 verbose lifecycle frontend@1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle frontend@1.0.0~build: PATH: /root/.nvm/versions/node/v8.6.0/lib/node_modules/npm/bin/node-gyp-bin:/var/www/app/frontend/node_modules/.bin:/root/.nvm/versions/node/v8.6.0/bin:/root/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle frontend@1.0.0~build: CWD: /var/www/app/frontend
10 silly lifecycle frontend@1.0.0~build: Args: [ '-c', 'next build' ]
11 silly lifecycle frontend@1.0.0~build: Returned: code: 137  signal: null
12 info lifecycle frontend@1.0.0~build: Failed to exec build script
13 verbose stack Error: frontend@1.0.0 build: `next build`
13 verbose stack Exit status 137
13 verbose stack     at EventEmitter.&lt;anonymous&gt; (/root/.nvm/versions/node/v8.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at EventEmitter.emit (events.js:213:7)
13 verbose stack     at ChildProcess.&lt;anonymous&gt; (/root/.nvm/versions/node/v8.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at ChildProcess.emit (events.js:213:7)
13 verbose stack     at maybeClose (internal/child_process.js:927:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid frontend@1.0.0
15 verbose cwd /var/www/app/frontend
16 verbose Linux 4.4.0-71-generic
17 verbose argv &quot;/root/.nvm/versions/node/v8.6.0/bin/node&quot; &quot;/root/.nvm/versions/node/v8.6.0/bin/npm&quot; &quot;run&quot; &quot;build&quot;
18 verbose node v8.6.0
19 verbose npm  v5.4.2
20 error code ELIFECYCLE
21 error errno 137
22 error frontend@1.0.0 build: `next build`
22 error Exit status 137
23 error Failed at the frontend@1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 137, true ]"><pre class="notranslate"><code class="notranslate">0 info it worked if it ends with ok
1 verbose cli [ '/root/.nvm/versions/node/v8.6.0/bin/node',
1 verbose cli   '/root/.nvm/versions/node/v8.6.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'build' ]
2 info using npm@5.4.2
3 info using node@v8.6.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle frontend@1.0.0~prebuild: frontend@1.0.0
6 info lifecycle frontend@1.0.0~build: frontend@1.0.0
7 verbose lifecycle frontend@1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle frontend@1.0.0~build: PATH: /root/.nvm/versions/node/v8.6.0/lib/node_modules/npm/bin/node-gyp-bin:/var/www/app/frontend/node_modules/.bin:/root/.nvm/versions/node/v8.6.0/bin:/root/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle frontend@1.0.0~build: CWD: /var/www/app/frontend
10 silly lifecycle frontend@1.0.0~build: Args: [ '-c', 'next build' ]
11 silly lifecycle frontend@1.0.0~build: Returned: code: 137  signal: null
12 info lifecycle frontend@1.0.0~build: Failed to exec build script
13 verbose stack Error: frontend@1.0.0 build: `next build`
13 verbose stack Exit status 137
13 verbose stack     at EventEmitter.&lt;anonymous&gt; (/root/.nvm/versions/node/v8.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at EventEmitter.emit (events.js:213:7)
13 verbose stack     at ChildProcess.&lt;anonymous&gt; (/root/.nvm/versions/node/v8.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:125:13)
13 verbose stack     at ChildProcess.emit (events.js:213:7)
13 verbose stack     at maybeClose (internal/child_process.js:927:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
14 verbose pkgid frontend@1.0.0
15 verbose cwd /var/www/app/frontend
16 verbose Linux 4.4.0-71-generic
17 verbose argv "/root/.nvm/versions/node/v8.6.0/bin/node" "/root/.nvm/versions/node/v8.6.0/bin/npm" "run" "build"
18 verbose node v8.6.0
19 verbose npm  v5.4.2
20 error code ELIFECYCLE
21 error errno 137
22 error frontend@1.0.0 build: `next build`
22 error Exit status 137
23 error Failed at the frontend@1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 137, true ]
</code></pre></div>


<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">Your Environment</h2>

<table role="table">
<thead>
<tr>
<th>Tech</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>next</td>
<td>3.2.2</td>
</tr>
<tr>
<td>node</td>
<td>8.6.0</td>
</tr>
<tr>
<td>OS</td>
<td>ubuntu 16.04</td>
</tr>
</tbody>
</table>
<p dir="auto">Here's the URL looks like,</p>
<p dir="auto"><a href="http://www.mydomain.com/suresh/450" rel="nofollow">www.mydomain.com/suresh/450</a></p>
<p dir="auto">Here <strong>suresh</strong> is parsed as "<strong>username</strong>" and <strong>450</strong> is parsed as "<strong>amount</strong>". Here's the <strong>server.js</strong> code<br>
`const express = require("express");<br>
const { parse } = require("url");<br>
const next = require("next");</p>
<p dir="auto">const dev = process.env.NODE_ENV !== "production";<br>
const app = next({ dev });<br>
const handle = app.getRequestHandler();</p>
<p dir="auto">app<br>
.prepare()<br>
.then(() =&gt; {<br>
const server = express();</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="server.get(&quot;/&quot;, (req, res) =&gt; {
  return handle(req, res);
});
server.get(&quot;/get-link&quot;, (req, res) =&gt; {
  return handle(req, res);
});
server.get(&quot;/:username/&quot;, (req, res) =&gt; {
  const actualPage = &quot;/processor&quot;;
  const mergedQuery = Object.assign(
    {},
    { reqQuery: req.query },
    { reqParams: req.params }
  );
  console.log('req', req);
  console.log('cProps', cProps);
  return app.render(req, res, actualPage, { cProps: mergedQuery });
});

server.get(&quot;/:username/:amount&quot;, (req, res) =&gt; {
  const actualPage = &quot;/processor&quot;;
  const mergedQuery = Object.assign(
    {},
    { reqQuery: req.query },
    { reqParams: req.params }
  );
  return app.render(req, res, actualPage, { cProps: mergedQuery });
});

server.get(&quot;*&quot;, (req, res) =&gt; {
  return handle(req, res);
});

server.listen(3005, err =&gt; {
  if (err) throw err;
  console.log(&quot;&gt; Ready on http://localhost:3005&quot;);
});"><pre class="notranslate"><code class="notranslate">server.get("/", (req, res) =&gt; {
  return handle(req, res);
});
server.get("/get-link", (req, res) =&gt; {
  return handle(req, res);
});
server.get("/:username/", (req, res) =&gt; {
  const actualPage = "/processor";
  const mergedQuery = Object.assign(
    {},
    { reqQuery: req.query },
    { reqParams: req.params }
  );
  console.log('req', req);
  console.log('cProps', cProps);
  return app.render(req, res, actualPage, { cProps: mergedQuery });
});

server.get("/:username/:amount", (req, res) =&gt; {
  const actualPage = "/processor";
  const mergedQuery = Object.assign(
    {},
    { reqQuery: req.query },
    { reqParams: req.params }
  );
  return app.render(req, res, actualPage, { cProps: mergedQuery });
});

server.get("*", (req, res) =&gt; {
  return handle(req, res);
});

server.listen(3005, err =&gt; {
  if (err) throw err;
  console.log("&gt; Ready on http://localhost:3005");
});
</code></pre></div>
<p dir="auto">})<br>
.catch(ex =&gt; {<br>
console.error(ex.stack);<br>
process.exit(1);<br>
});<br>
`<br>
In Dev mode, this URL <strong><a href="http://www.mydomain.com/suresh" rel="nofollow">www.mydomain.com/suresh</a></strong> and **<a href="http://www.mydomain.com/suresh/450**is" rel="nofollow">www.mydomain.com/suresh/450**is</a> working as expected, But after build and running in production its showing 404.</p>
<p dir="auto">Here's my package.json<br>
<code class="notranslate">{ "name": "stellar-me", "version": "1.0.0", "scripts": { "dev": "node server.js", "build": "next build", "start": "NODE_ENV=production next start" }, "dependencies": { "next": "5.0.0", "express": "4.16.2", "next-redux-wrapper": "^1.0.0", "react": "16.2.0", "react-dom": "16.2.0", "react-redux": "^5.0.1", "redux": "^3.6.0", "redux-devtools-extension": "^2.13.2", "redux-thunk": "^2.1.0", "stellar-sdk": "^0.8.0" }, "license": "ISC" } </code></p>
<p dir="auto">Please let me know whats happening.</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?q=is%3Aissue">issues</a> of this repository and believe that this is not a duplicate.</li>
</ul>


<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.0</td>
</tr>
<tr>
<td>node</td>
<td>6.10.3</td>
</tr>
<tr>
<td>OS</td>
<td>Ubuntu 16.04</td>
</tr>
<tr>
<td>browser</td>
<td>Chrome</td>
</tr>
<tr>
<td>etc</td>
<td></td>
</tr>
</tbody>
</table>