Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactDOM RSS renderToString production error

I created new boilerplate for react16.

https://github.com/jasonvillalon/react16-boilerplate

its working when running in development using:

npm start
npm start:webpack

but when running in production it throws error on renderToString

NODE_ENV=production npm start

the webpack succeeds without error but when rendering the page the error occur:

ERROR: TypeError: Cannot set property 'getCurrentStack' of undefined
at setCurrentDebugStack (webpack:///./node_modules/react-dom/cjs/react-dom-server.node.development.js?:1816:48)
at ReactDOMServerRenderer.read (webpack:///./node_modules/react-dom/cjs/react-dom-server.node.development.js?:2225:13)
at renderToString (webpack:///./node_modules/react-dom/cjs/react-dom-server.node.development.js?:2494:29)
at _callee$ (webpack:///./src/server.jsx?:66:49)
at tryCatch (/Users/jasonvillalon/Documents/fun-projects/from-scratch/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:65:40)
at Generator.invoke [as _invoke] (/Users/jasonvillalon/Documents/fun-projects/from-scratch/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:303:22)
at Generator.prototype.(anonymous function) [as next] (/Users/jasonvillalon/Documents/fun-projects/from-scratch/node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js:117:21)
at step (webpack:///./src/server.jsx?:27:191)
at eval (webpack:///./src/server.jsx?:27:437)
at new Promise (<anonymous>)

any body have an idea what is going on?

Best Regards, Jason

like image 519
JasonV Avatar asked Mar 07 '18 14:03

JasonV


1 Answers

The problem is that, in Webpack, you've set the following:

let config = {
  mode: "development",
....

But either on the Winblows / DOS command line you've set:

set NODE_ENV=production

Or on Linux you've set

export NODE_ENV=production

Or possibly in your webpack.config.js you've set:

let config = {
  ...

  new webpack.DefinePlugin({
    "process.env": {
      NODE_ENV: JSON.stringify("production")
    }
  })

To fix this, you either need to fix the top part:

let config = {
  mode: "production",
....

or unset the NODE_ENV environment variable.

Credit goes to @Jordan M Alperin from the comments above.

like image 57
Ryan Shillington Avatar answered Oct 30 '22 20:10

Ryan Shillington