首页 > 解决方案 > Next.js 在 Ubuntu EAGAIN 上构建失败

问题描述

我在 Ubuntu 18.04(4 核,8gb ram)上构建 next.js 应用程序时遇到问题。它在我的本地 Windows 机器上运行良好,但在我的 ci 服务器上失败并出现以下错误。该应用程序只是启用了 typescript 的初始默认应用程序。我在节点 v14.15.1 上。

错误:

frontend@0.1.0 build /root/builds/sbhwz7X3/0/xxx/xxx/frontend
next build

info  - Creating an optimized production build ...events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: spawn /usr/bin/node EAGAIN
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  errno: -11,
  code: 'EAGAIN',
  syscall: 'spawn /usr/bin/node',
  path: '/usr/bin/node',
  spawnargs: [
    '/root/builds/sbhwz7X3/0/xxx/xxx/frontend/node_modules/jest-worker/build/workers/processChild.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! frontend@0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the frontend@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-11-22T21_35_14_729Z-debug.log

包.json:

{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "export": "next export",
    "start": "next start"
  },
  "dependencies": {
    "next": "10.0.1",
    "react": "17.0.1",
    "react-dom": "17.0.1"
  },
  "devDependencies": {
    "@types/node": "^14.14.9",
    "@types/react": "^16.9.56",
    "typescript": "^4.0.5"
  }
}

在其他线程上,我读过有关进程限制干扰的信息,但看起来这应该不是问题。

ulimit -a:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 1029354
max locked memory       (kbytes, -l) 65536
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 62987
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

标签: node.jslinuxnext.js

解决方案


推荐阅读