未处理的“错误”构建react.js/next.js应用程序时发生的事件
在本地服务器上构建是可以的,但是如果我尝试在生产 Linux 服务器上构建,则会出现错误:
> next build
info - Loaded env from /home/*/*********/tech/public_html/.env.production
info - Checking validity of types
node:events:504
throw er; // Unhandled 'error' event
^
Error: spawn /home/*/*********/tech/nodejs/bin/node EAGAIN
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -11,
code: 'EAGAIN',
syscall: 'spawn /home/*/*********/tech/nodejs/bin/node',
path: '/home/*/*********/tech/nodejs/bin/node',
spawnargs: [
'/home/*/*********/tech/public_html/node_modules/next/dist/compiled/jest-worker/processChild.js'
]
}
尝试重新安装 node_modules,清理缓存,但没有任何变化。检查是否存在一些未处理的错误。
包.json:
{
"name": "*****",
"version": "1.0.0",
"description": "******",
"main": "index.js",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"mysql": "^2.18.1",
"next": "^12.1.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@types/mysql": "^2.15.21",
"@types/node": "^17.0.21",
"@types/react": "^17.0.40",
"eslint": "^8.11.0",
"eslint-config-next": "^12.1.0",
"typescript": "^4.6.2"
}
}
Building on local server is okey, but if I try building on production linux server, then get error:
> next build
info - Loaded env from /home/*/*********/tech/public_html/.env.production
info - Checking validity of types
node:events:504
throw er; // Unhandled 'error' event
^
Error: spawn /home/*/*********/tech/nodejs/bin/node EAGAIN
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:478:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -11,
code: 'EAGAIN',
syscall: 'spawn /home/*/*********/tech/nodejs/bin/node',
path: '/home/*/*********/tech/nodejs/bin/node',
spawnargs: [
'/home/*/*********/tech/public_html/node_modules/next/dist/compiled/jest-worker/processChild.js'
]
}
Tried to reinstall node_modules, clean cache but nothing changes. Checked if there are some unhandled errors.
package.json:
{
"name": "*****",
"version": "1.0.0",
"description": "******",
"main": "index.js",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"mysql": "^2.18.1",
"next": "^12.1.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@types/mysql": "^2.15.21",
"@types/node": "^17.0.21",
"@types/react": "^17.0.40",
"eslint": "^8.11.0",
"eslint-config-next": "^12.1.0",
"typescript": "^4.6.2"
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主要原因是 Timeweb 托管受到 40 个服务器进程的限制。如果不使用 typescript,那么您将收到类似“sh: 1: next: Permission returned”的错误。
The main cause is that Timeweb hosting is limited by 40 server processes. If don't use typescript, then you will have the error like "sh: 1: next: Permission denied".