lobehub / lobe-chat

🤯 Lobe Chat - an open-source, modern-design AI chat framework. Supports Multi AI Providers( OpenAI / Claude 3 / Gemini / Ollama / Azure / DeepSeek), Knowledge Base (file upload / knowledge management / RAG ), Multi-Modals (Vision/TTS) and plugin system. One-click FREE deployment of your private ChatGPT/ Claude application.
https://chat-preview.lobehub.com
Other
44.25k stars 9.91k forks source link

[Bug] Netlify部署提示内存不足 #2731

Closed S45618 closed 5 months ago

S45618 commented 5 months ago

📦 部署环境

📌 软件版本

Opera One(版本: 112.0.5179.0)

💻 系统环境

🌐 浏览器

🐛 问题描述

部署到构建阶段报错,问ai说是内存不足

AI的解答:⬇️『### 我在自己的fork更改后确实有用』

_“诊断: 在第 106 行出现错误 “JavaScript 堆已用完内存”,导致构建失败。该错误发生在尝试分配内存的构建阶段。

解决方法 要解决 “JavaScript 堆超出内存 ”问题,您需要在构建过程中增加 Node.js 的可用内存。您可以设置 max-old-space-size 标志来分配更多内存。如下所示,修改 netlify.toml 文件中的构建命令以包含此标记:

编译 命令 = “NODE_OPTIONS=--max_old_spacesize=4096 npm run build” 此命令将内存大小设置为 4 GB(4096 表示 4 GB),但您可以根据构建需求调整此值。”

报错代码:⬇️

3:23:49 AM: @netlify/plugin-nextjs (onEnd event)
3:23:49 AM: ──────────────────────────────────────────────────────────────── 3:23:49 AM: ​ 3:23:49 AM: ​ 3:23:49 AM: (@netlify/plugin-nextjs onEnd completed in 6ms) 3:23:49 AM: ​ 3:23:49 AM: "build.command" failed
3:23:49 AM: ──────────────────────────────────────────────────────────────── 3:23:49 AM: ​ 3:23:49 AM: Error message 3:23:49 AM: Command failed with exit code 134: npm run build (https://ntl.fyi/exit-code-134) 3:23:49 AM: ​ 3:23:49 AM: Error location 3:23:49 AM: In build.command from netlify.toml: 3:23:49 AM: npm run build 3:23:49 AM: ​ 3:23:49 AM: Resolved config 3:23:49 AM: build: 3:23:49 AM: command: npm run build 3:23:49 AM: commandOrigin: config 3:23:49 AM: environment: 3:23:49 AM: - ACCESS_CODE 3:23:49 AM: - OPENAI_API_KEY 3:23:49 AM: publish: /opt/build/repo/.next 3:23:49 AM: publishOrigin: config 3:23:49 AM: plugins: 3:23:49 AM: - inputs: {} 3:23:49 AM: origin: ui 3:23:49 AM: package: '@netlify/plugin-nextjs' 3:23:49 AM: Build failed due to a user error: Build script returned non-zero exit code: 2 3:23:49 AM: Failing build: Failed to build site 3:23:50 AM: Finished processing build request in 5m19.825s

📷 复现步骤

Initializing Complete

Building『这里出错』 Failed

Deploying Skipped

Cleanup Skipped

Post-processing Skipped

🚦 期望结果

快速部署

📝 补充信息

No response

lobehubbot commented 5 months ago

👀 @S45618

Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible. Please make sure you have given us as much context as possible.\ 非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。

S45618 commented 5 months ago

另外,请支持cloudlflare page部署,部署了一下,发现报错⬇️

01:50:20.868 | Cloning repository...
-- | --
01:50:22.040 | From https://github.com/S45618/lobe-chat-auto
01:50:22.040 | * branch            36ce76100e7aab528b21089595363444f7478ef6 -> FETCH_HEAD
01:50:22.040 |  
01:50:22.186 | HEAD is now at 36ce761 :bookmark: chore(release): v0.162.11 [skip ci]
01:50:22.186 |  
01:50:22.270 |  
01:50:22.270 | Using v2 root directory strategy
01:50:22.299 | Success: Finished cloning repository files
01:50:23.977 | Checking for configuration in a wrangler.toml configuration file (BETA)
01:50:23.977 |  
01:50:24.072 | No wrangler.toml file found. Continuing.
01:50:27.408 | Detected the following tools from environment: yarn@v0.162.11, nodejs@lts/hydrogen
01:50:27.409 |  
01:50:27.409 | Installing nodejs lts/hydrogen
01:50:27.409 |  
01:50:27.482 | mkdir: cannot create directory '/opt/buildhome/.asdf/installs/nodejs/lts/hydrogen': No such file or directory
01:50:27.912 | Trying to update node-build... ok
01:50:27.947 | node-build: definition not found: 18
01:50:27.955 | Error: Exit with error code: 1
01:50:27.956 | at ChildProcess. (/snapshot/dist/run-build.js)
01:50:27.956 | at Object.onceWrapper (node:events:652:26)
01:50:27.956 | at ChildProcess.emit (node:events:537:28)
01:50:27.956 | at ChildProcess._handle.onexit (node:internal/child_process:291:12)
01:50:27.967 | Failed: build command exited with code: 1
01:50:28.770 | Failed: error occurred while running build command

sxjeru commented 5 months ago

Netlify 构建内存不足,请尝试将下面配置项的值改为 node --max-old-space-size=4096 next build 再试试。 https://github.com/lobehub/lobe-chat/blob/2ee834458e02784d3a7a19f332742565ae79127e/netlify.toml#L2

CF Page 构建前,请删除根目录的 .nvmrc 文件。 此外由于 CF 免费计划对单文件大小限制在 25MB,所以本项目即使成功构建,也无法被部署。

lobehubbot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


The Netlify build has insufficient memory. Please try changing the value of the following configuration item to node --max-old-space-size=4096 next build and try again. https://github.com/lobehub/lobe-chat/blob/2ee834458e02784d3a7a19f332742565ae79127e/netlify.toml#L2


Before building CF Page, please delete the .nvmrc file in the root directory. In addition, since the CF free plan limits the size of a single file to 25MB, this project cannot be deployed after it is successfully built.

S45618 commented 5 months ago

Netlify 构建内存不足,请尝试将下面配置项的值改为 node --max-old-space-size=4096 next build 再试试。

https://github.com/lobehub/lobe-chat/blob/2ee834458e02784d3a7a19f332742565ae79127e/netlify.toml#L2

CF Page 构建前,请删除根目录的 .nvmrc 文件。 此外由于 CF 免费计划对单文件大小限制在 25MB,所以本项目即使成功构建,也无法被部署。

感谢解答👍

lobehubbot commented 5 months ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Netlify build has insufficient memory. Please try changing the value of the following configuration item to node --max-old-space-size=4096 next build and try again.

https://github.com/lobehub/lobe-chat/blob/2ee834458e02784d3a7a19f332742565ae79127e/netlify.toml#L2

Before building CF Page, please delete the .nvmrc file in the root directory. In addition, since the CF free plan limits the size of a single file to 25MB, this project cannot be deployed even if it is successfully built.

Thanks for the answer 👍