redux에서
import axios from 'axios';
Uncaught SyntaxError: Cannot use import statement outside a module (at bundle.js:38714:2)
1.x 버전의 axios가 node 환경용 commonJS가 아닌 ES Module로 빌드되었는데, jest는 node 환경에서 동작하기 때문에 오류가 발생한다고 함.
https://github.com/axios/axios/issues/5101
package.json을 아래와 같이 수정하면 된다고 해서 해봤으나 효과 없음.
"test": "react-scripts test --transformIgnorePatterns \"node_modules/(?!axios)/\"",
아래와 같이 0.x 버전으로 되돌려서 해결함.
yarn remove axios
yarn add axios@0
'programming > db, web, node.js' 카테고리의 다른 글
| [mongoDB v7] 2. Robo 3T client 설치, 실행 (0) | 2025.02.23 |
|---|---|
| [mongoDB v7] 1. server 설치, config, 실행 (0) | 2025.02.23 |
| [React] React Developer Tools - Components 탭에 아무것도 안 나올 때 (0) | 2025.01.11 |
| vscode typescript trace 방법 (1) | 2024.02.09 |
| [React] create-react-app 에러 대응 방법 (0) | 2024.02.09 |