未处理的“错误”构建react.js/next.js应用程序时发生的事件

发布于 2025-01-14 22:27:47 字数 6557 浏览 5 评论 0原文

在本地服务器上构建是可以的,但是如果我尝试在生产 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅听莫相离 2025-01-21 22:27:47

主要原因是 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".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文