Next.js: Build error only occurring on web server

Created on 11 Oct 2017  路  4Comments  路  Source: vercel/next.js


npm run build -> (next build) is working locally but on the production web server with the same code it gives the following error log:

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 [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 info lifecycle [email protected]~build: [email protected]
7 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~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 [email protected]~build: CWD: /var/www/app/frontend
10 silly lifecycle [email protected]~build: Args: [ '-c', 'next build' ]
11 silly lifecycle [email protected]~build: Returned: code: 137  signal: null
12 info lifecycle [email protected]~build: Failed to exec build script
13 verbose stack Error: [email protected] build: `next build`
13 verbose stack Exit status 137
13 verbose stack     at EventEmitter.<anonymous> (/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.<anonymous> (/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 [email protected]
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 [email protected] build: `next build`
22 error Exit status 137
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 137, true ]

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Your Environment


| Tech | Version |
|---------|---------|
| next | 3.2.2 |
| node | 8.6.0 |
| OS | ubuntu 16.04 |

Most helpful comment

I'm now getting this. Haha see what I did there? Anyways I'm trying to deploy to now and when it runs build it crashes with your same error. However locally it works great.

Gonna try to bounce down a version of Next. It just started happening as I updated.

All 4 comments

I'm now getting this. Haha see what I did there? Anyways I'm trying to deploy to now and when it runs build it crashes with your same error. However locally it works great.

Gonna try to bounce down a version of Next. It just started happening as I updated.

getting this too

I fixed this relatively soon after I got the error (actually forgot that I submitted this issue).

A few things to try:

  • Have you tried resetting npm installs (deleting node_modules folder) and re-installing dependencies?
  • Have you tried re-cloning your code in your production environment?

Going to close this then @james-ff 馃檹
Exit status 137 happens mostly in out of memory cases.

Was this page helpful?
0 / 5 - 0 ratings