hughsk / envify

:wrench: Selectively replace Node-style environment variables with plain strings.
902 stars 57 forks source link

Error if environment variable doesn't exist #1

Closed nicolashery closed 11 years ago

nicolashery commented 11 years ago

I don't know if this is intended, but say the environment variable NODE_ENV is not defined in my shell, then the transform leaves process.env.NODE_ENV as-is, which raises an error because process is not defined.

Maybe replace process.env.NODE_ENV with undefined instead?

hughsk commented 11 years ago

Hmm, that's strange... Browserify should be including process.env as an empty object, but maybe that's changed in a recent version? process should definitely be defined too. I'll look into it, thanks for the heads up! :)

hughsk commented 11 years ago
console.log(process.env.NODE_ENV)

Without NODE_ENV seems to work fine for me (it logs undefined), are you able to post your code? Thanks :)

nicolashery commented 11 years ago

My bad. You're right, I checked and I had detectGlobals: false in my Gruntfile.js. I removed it and Browserify shims process as expected. Still wrapping my head around Browserify's options :)

Thanks! Nicolas