'React' was used before it was defined

前端 未结 14 2110
傲寒
傲寒 2020-12-29 19:28

I am working with create-react-app + typescript + eslint application and during build have such error:

Line 1:8:  \'React\' was used before it was defined  @t         


        
14条回答
  •  一向
    一向 (楼主)
    2020-12-29 20:03

    Not enough credit to comment.

    @sashko thank you for your answers.

    I just wanted to add that for me, I did the following.

    1. Removed all eslint related dependencies from package.json if they were already included in package-lock.json by react-scripts (for me that was all of them)
    2. Deleted my node_modules folder, and package-lock.json file
    3. npm install

    After completing those steps I finally got that error to go away. I prefer removing the dependencies to downgrading them since this will help avoid the same issue happening again in the future.

提交回复
热议问题