본문 바로가기
안녕 버그친구들

리액트 node_modules decorator 관련 오류

by 정ㅇr 2021. 11. 10.
728x90

먼저 관련 버그 문구는 아래와 같다.

SyntaxError: /App.js: Support for the experimental syntax 'decorators-legacy' isn't currently enabled

 

업무를 하다가 깃허브에서 프로젝트를 새로 다운로드 받고 npm i -> npm start 로 프로젝트를 실행하니까 위와 같은 버그가 생겼다.

다운로드 한 프로젝트는 mobX를 사용하고 있어서 decorator가 필요한데,

node_modules/babel-preset-react-app 경로의 create.js 파일에서 

// Turn on legacy decorators for TypeScript files
      isTypeScriptEnabled && [
        require('@babel/plugin-proposal-decorators').default,
        { legacy: true }, // false에서 다음과 같이 변경
      ],

다음과 같이 false -> { legacy: true } 로 변경하면 decorator를 정상적으로 사용할 수 있게 된다.

 

반응형

댓글