question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to compile after install eslint locally (propTypes is not defined)

See original GitHub issue

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

image

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected):
test@0.1.0 /Users/dinhquangtrung/Desktop/test
└── react-scripts@1.0.7
  1. node -v:
v8.1.0
  1. npm -v:
5.0.3

Then, specify:

  1. Operating system: OSX Sierra
  2. 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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (14 by maintainers)

github_iconTop GitHub Comments

31reactions
shrynxcommented, Jun 13, 2017

@trungdq88 React removed PropTypes since version 15.5, see here you can use prop-types package for it.

15reactions
vcarelcommented, Jun 21, 2017

I got that same error on a state variable defined at class level. I guess it is the same issue, isn’t it ?

export default class MyComponent extends Component {
  state = {
    open: true
  }
Failed to compile.

./src/components/MultiSelect/index.js
  Line 7:  'state' is not defined  no-undef
Read more comments on GitHub >

github_iconTop Results From Across the Web

'Proptypes' is not defined - Stack Overflow
I'm receiving the following linting error 'PropTypes' is not defined. (no-undef) . Here is the code that is causing the issue: import React,...
Read more >
[Solved]-'Proptypes' is not defined-Reactjs - appsloveworld
According to this issue comment. It appears to be because you have installed eslint 4.x when you should just use the eslint version...
Read more >
Resolve types from React 'prop-types' : WEB-26418 - YouTrack
I have Webstorm 2018.2 EAP, React 16.4.0, "prop-types" package installed locally (15.6.1), have invalidated caches, add the PropTypes type definitions and ...
Read more >
How To Customize ESLint Rules with an Ejected Create React ...
In this article, you will explore the reasons why we should utilize a linter like ESLint and how to customize it in a...
Read more >
eslint-plugin-react - npm
It is also possible to install ESLint globally rather than locally (using npm install eslint --global). However, this is not recommended, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found