Next.js: PropTypes error in production

Created on 23 May 2017  路  7Comments  路  Source: vercel/next.js

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!

Most helpful comment

Having the same issue :/ updating react didn't work

Edit: Updating also react-dom worked

All 7 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

swrdfish picture swrdfish  路  3Comments

timneutkens picture timneutkens  路  3Comments

flybayer picture flybayer  路  3Comments

kenji4569 picture kenji4569  路  3Comments

formula349 picture formula349  路  3Comments