2skydev / Notion-Next.js-blog-starter-kit

Notion + Next.js Blog Starter Kit - Next.js + Notion ISR static page blog starter kit
https://blog.2skydev.com
91 stars 60 forks source link

Error: An unexpected error occurred! #63

Closed worldinyj closed 3 months ago

worldinyj commented 4 months ago

아래의 에러는 왜 일까요? 로컬에서는 제대로 동작하고 서버에 올리고는 안되네요. 참고로 서버는 chemicloud라는 회사의 cPanel이라는 겁니다. 스크린샷 2024-05-13 204804

[asoso.secondlife.lol (20)] [secondl1@rs3-sgp asoso.secondlife.lol]$ npm run deploy

nextjs-notion-starter-kit@1.0.13 deploy vercel deploy

Vercel CLI 34.1.11 Error: An unexpected error occurred! RangeError: WebAssembly.instantiate(): Out of memory: Cannot allocate Wasm memory for new instance at lazyllhttp (eval at requireWithFakeGlobalScope (/home/secondl1/nodevenv/asoso.secondlife.lol/20/lib/lib/node_modules/vercel/dist/index.js:108386:11), :9988:32)

No existing credentials found. Please log in: ? Log in to Vercel (Use arrow keys) ❯ Continue with GitHub Continue with GitLab Continue with Bitbucket Continue with Email Continue with SAML Single Sign-On ───────────────────────────────── Cancel

worldinyj commented 4 months ago

vercel 쪽 문제인가 싶어서 직접 vercel에서 pro trial을 적용해서 deploy했더니 아래와 같은 에러가 나네요.

[21:22:37.562] Running build in Washington, D.C., USA (East) – iad1 [21:22:37.735] Cloning github.com/holyrich/Notion-Next.js-blog-starter-kit (Branch: main, Commit: 5b8d975) [21:22:37.750] Skipping build cache, deployment was triggered without cache. [21:22:38.373] Cloning completed: 637.89ms [21:22:38.942] Running "vercel build" [21:22:40.014] Vercel CLI 34.1.10 [21:22:42.115] Warning: Detected "engines": { "node": ">=16" } in your package.json that will automatically upgrade when a new major Node.js Version is released. Learn More: http://vercel.link/node-version [21:22:42.150] Installing dependencies... [21:22:42.777] yarn install v1.22.19 [21:22:42.892] error An unexpected error occurred: "Invalid value type 772:0 in /vercel/path0/yarn.lock". [21:22:42.895] info If you think this is a bug, please open a bug report with the information provided in "/vercel/path0/yarn-error.log". [21:22:42.895] info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. [21:22:42.919] Error: Command "yarn install" exited with 1 [21:22:43.226]

2skydev commented 4 months ago

vercel 오류 같은 경우 yarn.lock 파일 문제로 보이며 로컬에서 해당 파일을 삭제 후 다시 yarn 명령어로 패키지 재설치 후 커밋 부탁드립니다.

cPanel 오류는 아마 메모리 부족 문제로 보입니다

worldinyj commented 4 months ago

찾아보니 아래의 것이 있네요. https://github.com/vercel/next.js/issues/51870#issuecomment-2106330458

In version 13.5.6, it worked for me, definitively!!! After testing various methods, I finally resolved the memory error issue RangeError: WebAssembly.instantiate(): Out of memory: wasm memory using this approach.

1- To deploy, don't fetch the app build from the cpanel terminal. Instead, obtain it locally and upload the .next folder to the cpanel host. Otherwise, the memory error persists.

2- Note that if your local operating system is Windows and you've built the Next.js app on a Windows system, the built version won't work on a Linux cpanel host. You'll need Docker assistance.

3- First, run the app on Docker, then extract the .next folder from the Docker image to your local system. Upload the .next folder to the cpanel host, and you'll see the site running smoothly.

4- Here's a simple Dockerfile for creating a Docker image:

FROM node:20.9.0

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install COPY . .

RUN npm run build

CMD ["npm", "start"] 5- Build the image in CMD:

docker build -t nextjs-sample . 6- Extract the .next folder from the Docker image. Pay attention to the paths; the first path is for Docker, the second for extraction on the local system, and container_id is the container code, in CMD.

docker cp [container_id]:/usr/src/app/build /output 7- Upload ".next" folder to cpanel host

문제는 이걸로 도커 이미지를 빌드할 때 react와 react-dom 버전이 react-use 버전이랑 안맞다고 나오네요. 이건 이상하게도 계속 나오는 문제네요.

메모리의 경우는 대략 2G안되게 먹는거 같은데 호스팅서버에서는 3G까지 지원된다고 하구요.

계속 파봐야할 것 같습니다.