익스플로의 아카이브
Yarn V1에서 V4로 마이그레이션하는 방법
Yarn V1에서 V4로 마이그레이션하는 방법
2024.03.11Yarn V1에서 의존성을 추가하면 CommonJS, ESM 모듈 간 충돌하는 이슈가 지속적으로 발생해서 Yarn V4로 마이그레이션 하는 작업을 진행하였다. 본 글에서는 Yarn Classic이라고 부르는 V1에서 Yarn Berry(Yarn V2+을 지칭하는 명칭)로 마이그레이션 하는 방법에 대해 알아본다. 1. Yarn 버전 확인 yarn -v 를 입력해서 현재 yarn 버전을 확인한다. 명령어를 실행하니 1.22.22 버전이 설치되어 있다. $ yarn -v 1.22.22 2. Node 버전 확인 Yarn Berry로 업그레이드하기 위해서는 Node.js 18 버전 이상이 설치되어있어야 한다. node -v 명령어로 버전을 확인해 보니 20.10.0 버전이 설치되어 있다. 만약 18 버전보다 낮다..
[오류해결] ESLint 'test' is not defined. no-undef
[오류해결] ESLint 'test' is not defined. no-undef
2024.03.11오류 발생 테스트코드를 작성했는데 VSCode에서 아래의 오류 상세처럼 'test' is not defined.라는 eslint의 no-undef유형의 오류가 발생했다. 오류 상세 원인 분석 ESLint의 설정 파일에 Jest와 관련된 설정들이 추가되어있지 않아서 발생한 문제이다. 해결 방법 .eslintrc.cjs파일에 다음과 같이 "jest/globals"설정 값을 추가하면 오류메시지가 더 이상 나타나지 않는다. module.exports = { ...생략... env: { ..., "jest/globals": true, }, ...생략... } 참고 자료 https://stackoverflow.com/questions/55807824/describe-is-not-defined-when..
[오류해결] Error [ERR_REQUIRE_ESM]: require() of ES Module ~ node_modules/cliui/build/index.cjs not supported.
[오류해결] Error [ERR_REQUIRE_ESM]: require() of ES Module ~ node_modules/cliui/build/index.cjs not supported.
2024.03.11오류 발생 yarn test 명령어로 테스트 코드를 실행하려는데 아래와 같이 오류가 발생했다. yarn v1.22.21 node 20.10.0 오류 상세 yarn test yarn run v1.22.21 $ jest Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/iksflow/${PROJECT_ROOT}/node_modules/string-width/index.js from /Users/iksflow/${PROJECT_ROOT}/node_modules/cliui/build/index.cjs not supported. Instead change the require of index.js in /Users/iksflow/${PROJECT_ROOT}/node..
[오류해결] 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.
[오류해결] 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.
2024.03.10오류 발생 VSCode에서 Typecript + React 환경으로 개발을 하던 중 에디터에 React 컴포넌트에 붉은줄이 마구 생기면서 아래와 같은 오류가 발생했다. 딱히 건드린 코드가 없는데 갑자기 발생한 오류라 당황스러웠다. 오류 상세 'React' refers to a UMD global, but the current file is a module. Consider adding an import instead. 원인 분석 React 16에서 React 17로 넘어가면서 JSX Transformation 방식이 변했는데 이로 인해 발생하는 문제라고 한다. React 17에서 Transformation과 관련해 변경된 부분은 2가지이다. 첫 번째는 기존에는 React 컴포넌트 코드에 i..