create-react-app: Failed to compile after install eslint locally (propTypes is not defined)
If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely.
Can you reproduce the problem with latest npm?
Yes, on OSX Sierra.
Description
create-react-app test
cd test/
yarn add eslint
yarn start
Expected behavior
Should compile successfully.
Actual behavior
yarn start
failed to compile, showing error: propTypes is not defined
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
(if you haven’t ejected):
test@0.1.0 /Users/dinhquangtrung/Desktop/test
└── react-scripts@1.0.7
node -v
:
v8.1.0
npm -v
:
5.0.3
Then, specify:
- Operating system: OSX Sierra
- Browser and version: (any)
Reproducible Demo
Repo: https://github.com/trungdq88/create-react-app-issue Travis Build: https://travis-ci.org/trungdq88/create-react-app-issue/builds/242429125
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (14 by maintainers)
@trungdq88 React removed
PropTypes
since version 15.5, see here you can use prop-types package for it.I got that same error on a
state
variable defined at class level. I guess it is the same issue, isn’t it ?I had the same problem on a project with eslint installed globally. I solved this case by installing in eslint project: npm i eslint --save
bye jeff
If you mean that you installed
eslint
locally in your project, this is not really supported. I know that people do this, but we don’t recommend it.You don’t need to install it locally, it will work out of the box. Installing it locally can mess up the versions, which is what probably happened.