cp -r public .next/standalone/
https://nextjs.org/docs/pages/api-reference/config/next-config-js/output
next.config.js Options: output | Next.js
Next.js automatically traces which files are needed by each page to allow for easy deployment of your application. Learn how it works here.
nextjs.org
이대로만 하면 된다.
Next 에는 다양한 방법의 배포방법이 있다고 합니다.
나는 그중 한가지를 작성 할 예정입니다.
프로젝트를 완성시키고 이상이 없으면
npm run build 를 우선 해본다. 오류가있다면 잡아주자.
없다면 추가 수정이 필요합니다.
./next.config.ts
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
/* config options here */
output: 'standalone'
// output 항목을 추가하였습니다.
};
export default nextConfig;
다시 npm run build
그럼 .next 파일안에 standalone 파일이 생겼을것이다.
그리고 터미널을 열고 그대로 복붙
cp -r public .next/standalone/
public 파일 = 공통파일 이미지를 넣어누었던 파일이다.
cp -r .next/static .next/standalone/.next/
./next/static 파일 = 정적파일들이 들어가있다.
그리고 서버에 원하는 위치에 [project]/.next 파일을 통째로 옴긴다.
그리고 서버에서 파일일에 들어간다음
node .next/standalone/server.js
이렇게 하면 동작 후 잘 된다.
에러없이 잘해서
나머지 오류는 알아서 잘...열씸히...고쳐주세요...
'next ts( next.js, typescript)' 카테고리의 다른 글
NginX로 Next 배포하기(standalone, export) 맞을까? (0) | 2025.03.07 |
---|---|
Next.js ts 로 시작하기 for VsCode (0) | 2025.02.06 |