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


#1

Hi!

After upgrading Meteor from v1.4.4.4 to v.1.5.4.1, 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: https://github.com/meteor/meteor/issues/6402#issuecomment-300343883

Unfortunately only a hack is proposed.

Any help is greately appreciated, thanks!


#2

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:

https://atmospherejs.com/mrt/allow-env

After removing it, things are working out fine again.