parsing error: unexpected token

Lee Soyeon·2022년 4월 23일
0

프로젝트

목록 보기
6/6

리액트 parsing error: unexpected token

에러날 경우,

.eslintrc 파일 생성, 아래코드 추가할 것

 {
   "parser": "babel-parser"
 }

위 코드를 작성해 parser를 babel parser로 설정해주면 최신 ECMA 버전 사용 가능

만약, 타입스크립트도 사용하고 있다면

npm install --save-dev @typescript-eslint/parser
설치 후, 아래 코드 작성

{
  "extends": [
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended"
  ],
  "parser": "@typescript-eslint/parser",
  "plugins": ["@typescript-eslint"],
  "overrides": [
    {
      "files": ["*.js", "*.jsx"],
      "rules": {
        "@typescript-eslint/explicit-function-return-type": "off"
      }
    }
  ]
}

참고: https://r4bb1t.tistory.com/68

profile
프론트엔드 개발자가 되기 위해 공부하고 있습니다.

0개의 댓글