본문 바로가기
React/React Error

[React Error] Parsing error: Cannot find module 'next/babel'

by fefe94 2022. 1. 24.

문제

 

 

같은 워크스페이스 내에 다른 프로젝트에서

타입스크립트와 codegen을 깔고 나서

또 다른 프로젝트에서 갑자기

 

Parsing error: Cannot find module 'next/babel'

 

이런 에러가 나면서

import가 안받아지면서

코드가 작동이 되지 않았다.

 

같은 워크스페이스 내에서

또 다른 프로젝트를 새로 만들어도

다른 워크스페이스를 파서 새로 해봐도

같은 에러가 나면서 에러가 떴다.

 

 


 

해결

 

에러가 나는 프로젝트에

eslint 깔고 .eslintrc.json파일의 extends 에

next/babel을 추가하였다.

 

 

{
  "extends": ["next/babel", "next/core-web-vitals"]
}

.eslintrc.json 파일

 

 

 


 

 

조언 받았던 추가 해결 방법들)

 

1.

프로젝트의 최상단 위치에서

.babelrc 라는 파일을 만들고

그 안에 { "presets": ["next/babel"], "plugins": [] } 내용 추가 후 확인.

 

2.

.eslintrc.json파일의 extends 에  next/babel 이 포함되어있는지

확인해보고 없으면 넣기. 그래도 안된다면 yarn add babel-eslint -D 시도.

 


Reference

 

https://stackoverflow.com/questions/68163385/parsing-error-cannot-find-module-next-babel

 

Parsing error : Cannot find module 'next/babel'

I have been encountering this error on every single new Next.js project that I create. The page can be compiled without any problem, it just keeps on showing as error on the first line in every js ...

stackoverflow.com

 

댓글