Javascript/Next

[NEXTJS] ANTD SyntaxError: Unexpected token 'export'

eulBlue 2025. 1. 1. 02:38

📱테스트 환경

"next": "15.1.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",

해당 에러만 잡고 잔다는게 .. 벌써 새벽 2시 36분 ..

ChahGPT 도 자꾸 거짓말만 하고 해결못해서 진짜

너무 피곤하고 화나는 상황에 열심히 구글링을 통해

역시 공식홈페이지만한게 없다 징짜 ..

 

NextJs 14.0.3 issue · Issue #46053 · ant-design/ant-design

Reproduction link https://ibb.co/tHKtCc7 Steps to reproduce just update nextjs to latest version and you will see there's an issue with antd config provider What is expected? expecting to work as b...

github.com

여기서 해결 방법을 찾았고 방법은 다음과 같다.

import type {NextConfig} from "next";

const nextConfig: NextConfig = {
    /* config options here */
    reactStrictMode: true,
    transpilePackages: [
        // antd & deps
        "@ant-design",
        "@rc-component",
        "antd",
        "rc-cascader",
        "rc-checkbox",
        "rc-collapse",
        "rc-dialog",
        "rc-drawer",
        "rc-dropdown",
        "rc-field-form",
        "rc-image",
        "rc-input",
        "rc-input-number",
        "rc-mentions",
        "rc-menu",
        "rc-motion",
        "rc-notification",
        "rc-pagination",
        "rc-picker",
        "rc-progress",
        "rc-rate",
        "rc-resize-observer",
        "rc-segmented",
        "rc-select",
        "rc-slider",
        "rc-steps",
        "rc-switch",
        "rc-table",
        "rc-tabs",
        "rc-textarea",
        "rc-tooltip",
        "rc-tree",
        "rc-tree-select",
        "rc-upload",
        "rc-util",
    ]
};

export default nextConfig;

Nextjs 최신버전과 Antd 가 아직 잘 안되는 것 같았고

해당 transpilePackages 에 추가해주면 해결 !!

진짜 .. 이거 글만 쓰고 바로잘꺼야 ㅠㅠ

'Javascript > Next' 카테고리의 다른 글

[NEXTJS] Google Analytics 연결  (2) 2024.11.09
[NEXTJS] styled-components 적용  (0) 2024.11.08
[NEXTJS] Sentry 연결  (2) 2024.11.07
[JavaScript] Canvas 글자에 그림자 효과  (2) 2023.10.26
[NextJS] base64 Image ReSize  (0) 2023.09.01