process.env access in .next/bundles/pages/index.js
- [x] I have searched the issues of this repository and believe that this is not a duplicate.
gaearon/react-hot-loader/issues/356 is the closest I found.
Expected Behavior
Error free .next/bundles/pages/index.js
Current Behavior
Firefox throws:
process.env is undefined
Chromium says:
TypeError: Cannot read property 'NODE_ENV' of undefined
both originate from:
;(function register() { /* react-hot-loader/webpack */ if (process.env.NODE_ENV !== 'production') { if (typeof __REACT_HOT_LOADER__ === 'undefined') { return; }
In most places the generated index.js reads:
;(function register() { /* react-hot-loader/webpack */ if (true) { if (typeof __REACT_HOT_LOADER__ === 'undefined') { return; }
Something, and I can't figure out what, triggered webpack and/or react-hot-loader to use "process.env.NODE_ENV" in the front-end, which kills it.
Context
"next dev" is rendered useless, because the hot-reload feature breaks the front-end coding.
Your Environment
| Tech | Version |
|---|---|
| next | 4.1.4 |
| node | 6.12.0 |
| OS | Ubuntu 17.10 |
| browser | Firefox and Chromium |
Any help would be greatly appreciated. Banging my head against the wall since days :( Unfortunately I wasn't able to create a minimal-example, so if any code is required I will happily share it.
The root-cause was the following line of code in one of my redux-reducers:
const process = reducer({finished: false}, {
[FINISH_COMPARISON_PROCESS]: () => {}
});
Because the register() function isn't properly scoped, "process" gets overriden and doesn't contain "env" anymore. Which broke the code.
The solution was as easy as renaming the variable to "ratingProcess".