⚠️ 오류 발생 | 'import' and 'export' may appear only with 'sourceType: module'

noopy·2021년 8월 20일
0

⚠️ 오류발생

목록 보기
1/3

'import' and 'export' may appear only with 'sourceType: module'

🧐 원인

ESLint natively doesnt support this because this is against the spec. But
if you use babel-eslint parser then inside your eslint config file.

명세서와 어긋나기 때문에 ESLint에서 지원하지 않으므로, bable-eslint parser를 사용해야 한다.

😎 해결방안

package.json 파일 하단부에 eslintConfig 프로퍼티를 추가한다.

"eslintConfig": {
    "parserOptions": {
      "parser": "babel-eslint",
      "sourceType": "module",
      "allowImportExportEverywhere": true
    }
  }

sourcetype 'module' is not supported when ecmaversion 2015 오류가 추가로 발생 시
parserOptions"ecmaVersion": 2015를 추가한다.

"eslintConfig": {
    "parserOptions": {
      "parser": "babel-eslint",
      "sourceType": "module",
      "allowImportExportEverywhere": true,
      "ecmaVersion": 2015
    }
  }

참고 사이트)

Example eslint config in a package.json

profile
💪🏻 아는 걸 설명할 줄 아는 개발자 되기

0개의 댓글