ESLint에서 import/export 구문을 사용해도 오류로 간주하지 않도록 다음과 같이 .eslintrc.json에서 sourceType 값을 "module"로 설정해 주세요.
.eslintrc.json
{
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"extends": ["eslint:recommended", "prettier"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"no-unused-vars": "warn",
"no-console": "off"
}
}
이제 프로젝트에서 import/export 구문을 자유롭게 사용할 수 있습니다! 그리고 이전에 만들었던 모듈을 하나하나 수정해 주겠습니다.
기존에 실행 중이던 서버는 종료하고, 다시 yarn start:dev 명령어를 입력하여 새로운 스크립트로 서버를 구동하세요.