Unable to use process.env to get environment variable in ~/.profile or ~/.bash_profile in Mac

I am trying to get environment variables in a node.js (using node-webkit) application on Mac and I am unable to.

I added the entry

export MY_PROJECT=\Library\MrProject

in both ~/.bash_profile and ~/.profile.

I did source both and when I try to access process.env.MY_PROJECT it returns undefined. I tried to access process.env and it runs few things but it doesn't return the environment variables I am exporting in ~/.profile and/or ~/.bash_profile.

You need to source ~/.bash_profile when you modify profile files. Or logout and login to make it take into effect. Try replacing process.env.MY_PROJECT with process.env.PATH to test.