I get this error when I run next build && NODE_ENV=production node server.js (my app uses a simple Express server for custom routing):
Uncaught TypeError: Cannot read property 'PropTypes' of undefined
The app runs fine in dev mode (with command nodemon server.js). I have switched to importing PropTypes from the prop-types package instead of from React, so (I think) that's not the problem.
I'm using Flow for the vast majority of my type checking - I only use PropTypes for context, in this HOC component and this other component.
Next version: 2.3.1
React: 15.4.2
Full stack trace (unfortunately not very useful because the code is minified in production):
Uncaught TypeError: Cannot read property 'PropTypes' of undefined
at Object.o.23.113 (app.js:185)
at a (app.js:185)
at app.js:185
at Object.o.38.113 (app.js:185)
at a (app.js:185)
at app.js:185
at Object.o.31.10 (app.js:185)
at a (app.js:185)
at app.js:185
at Object.o.47.1 (app.js:185)
I've been stuck trying to figure this out for a couple days, so any help would be greatly appreciated. Thanks in advance!
can you share more of the component code here @nwshane ? I'm using prop-types and haven't had any issues with production deploys.
@nwshane got the same issue.
Use the latest version of React (15.5.x). That'll fix the issue.
@nwshane reopen this issue if my ^^^ suggestion didn't fix your issue.
@arunoda That fixed it! Thanks!
Having the same issue :/ updating react didn't work
Edit: Updating also react-dom worked
Suggestion: Add a warning for outdated React if Next won't work with outdated React. Had the same problem.
I had the same problem after updating next.js
Will try updating React / React-DOM
Most helpful comment
Having the same issue :/ updating react didn't work
Edit: Updating also react-dom worked