Upgrade of Meteor: Uncaught TypeError: Cannot read property 'NODE_ENV' of undefined


After upgrading Meteor from v1.4.4.4 to v., React throws this error:

“Uncaught TypeError: Cannot read property ‘NODE_ENV’ of undefined”

This is the line where the error is thrown:

if (process.env.NODE_ENV === ‘production’) {

The same happens for Meteor v1.6.

So far, I understand that process.env is only defined on the server. And therefore, the client-side react code fails.

And while googling I have seen some topics that seem to propose to use “envify” to solve this problem, replacing occurrences of process.env.NODE_ENV with the constant “production/development”. But I just couldn’t find a way how to integrate envify into the meteor build process. Or any other way around the issue…

Here is also an issue, heading into the right direction: Client side bundling doesn't eliminate dead code in production · Issue #6402 · meteor/meteor · GitHub

Unfortunately only a hack is proposed.

Any help is greately appreciated, thanks!

Alright, I found the problem by re-installing meteor/react and copying over the files, folder by folder. I was using a package called allow-env which caused the error:


After removing it, things are working out fine again.

1 Like