ERROR

[Error] 'React' refers to a UMD global, but the current file is a module

숭코기 2023. 8. 17. 22:54
728x90

 

 

JS 파일을 TS로 변환 하던 중 발생한 에러

 

 

해결방법

 

1. package.json 에서 모듈 버전을 확인하고 업데이트 하자.

- typescript: 최소 4.1 버전

- react, react-dom: 최소 17 버전

 

2. tsconfig.json 에서 jsx 옵션을 'react'가 아닌 'react-jsx' 또는 'react-jsxdev'로 변경해주자.

 

 

📌 출처

https://stackoverflow.com/questions/64656055/react-refers-to-a-umd-global-but-the-current-file-is-a-module

 

'React' refers to a UMD global, but the current file is a module

I updated my project to create react app 4.0, and I'm slowing moving over my files to TypeScript. I know with this new version you don't have to repetitively import React from 'react'. However, wit...

stackoverflow.com

 

728x90