无法使用process.env在〜/ .profile或〜/ .bash_profile中获取环境variables

我正在尝试在Mac上的node.js(使用node-webkit)应用程序中获取环境variables,我无法。

我添加了条目

导出MY_PROJECT = \ Library \ MrProject

在〜/ .bash_profile和〜/ .profile中。

我没有源代码,当我尝试访问process.env.MY_PROJECT它返回未定义。 我试图访问process.env,它运行的东西很less,但它不会返回我在〜/ .profile和/或〜/ .bash_profile中导出的环境variables。

修改configuration文件时,您需要获取source ~/.bash_profile 。 或注销并login以使其生效。 尝试用process.env.MY_PROJECTreplaceprocess.env.MY_PROJECT来testing。