240312 개발일지 TIL - Module not found: Can't resolve 'child_process'

The Web On Everything·2024년 3월 11일
0

개발일지

목록 보기
261/269

Module not found: Can't resolve 'child_process'

Import trace for requested module:
./node_modules/execa/index.js
./node_modules/@shadcn/ui/dist/index.js
./src/components/PaymentForm.tsx
./src/pages/payment.tsx
 ⨯ ./node_modules/cross-spawn/index.js:3:0
Module not found: Can't resolve 'child_process'

https://nextjs.org/docs/messages/module-not-found

문제 발생

shadcn/ui를 설치하고 페이지를 연결해 화면을 구성하려던 중 발생한 현상

시도한 방법

패키지를 몇 번이고 재설치해보아도 같은 현상이 발생

해결 방법

"browser":{
"child_process": false
}  

package.json에 위 부분을 추가해준다.

nextJS의 경우

  webpack: (config, { isServer }) => {
    if (!isServer) {
      config.resolve.fallback.fs = false;
      config.resolve.fallback.tls = false;
      config.resolve.fallback.net = false;
      config.resolve.fallback.child_process = false;
    }

    return config;
  },

next.config.mjs에 위 부분을 추가해준다.

느낀 점

gpt한테 물어보니 산으로 가는 듯한 답변들만 가득해
스택오버플로우에서 해당 답변을 얻어 해결했다.
역시 스택오버플로우!!!
gpt4도 3.5버전보다야 낫지만 보조 역할만 요청하도록 하자.

profile
오늘은 무슨 오류를 만날까?! 널 만나러 가는 길~ LOL

0개의 댓글