[RN] Cannot find module '@babel/core'

헤테로·2025년 3월 27일

React Native

목록 보기
2/4

Cannot find module '@babel/core'
발생 위치: /index.ts 파일 안에서

이건 Babel이 프로젝트에서 핵심 모듈인 @babel/core를 찾지 못하고 있다는 뜻이다.


💥 원인 요약

@babel/coreTypeScript나 JSX 같은 최신 문법을 JavaScript로 변환하는 데 꼭 필요한 Babel의 핵심 모듈이다.
이게 없으면 프로젝트가 빌드도, 실행도 안 된다.


✅ 해결 방법


🔧 1단계: @babel/core가 설치되어 있는지 확인

터미널에서 프로젝트 폴더 안으로 들어가서 아래 명령어 입력:

npm ls @babel/core

만약 아래처럼 나온다면 ❌ 설치 안 된 상태:

-- @babel/core@MISSING

✅ 2단계: 설치하기

아래 명령어로 @babel/core와 필요한 Babel 프리셋도 같이 설치한다.

npm install --save-dev @babel/core @babel/preset-env @babel/preset-react @babel/preset-typescript

또는 yarn 쓰는 경우:

yarn add --dev @babel/core @babel/preset-env @babel/preset-react @babel/preset-typescript

💡 Expo 환경이면 이걸 직접 쓸 일이 거의 없지만, React Native CLI 환경이거나 커스터마이징한 경우 꼭 필요하다.


✅ 3단계: .babelrc 또는 babel.config.js 확인

babel.config.js가 있다면 아래처럼 설정되어 있어야 해:

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
};

만약 TypeScript를 쓰고 있다면:

module.exports = {
  presets: [
    'module:metro-react-native-babel-preset',
    '@babel/preset-typescript',
  ],
};

이렇게 하니까 됐어염 ^___^

profile
해야할 것들을 합니다

0개의 댓글