无法使用进程.获取~/中的环境变量.配置文件或~/.Mac中的bash_profile

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

本文关键字:配置文件 Mac 中的 profile bash 环境变量 进程 获取      更新时间:2023-09-26

我试图在Mac上的node.js(使用node-webkit)应用程序中获得环境变量,我无法。

我添加了

条目出口MY_PROJECT = '图书馆' MrProject

中的~/。Bash_profile和~/.profile.

我做源和当我试图访问process.env。MY_PROJECT返回undefined。我试着进入程序。它运行一些东西,但它不返回我导出到~/的环境变量。Profile和/或~/.bash_profile.

修改配置文件时需要使用source ~/.bash_profile。或者注销并登录使其生效。试着用process.env.PATH代替process.env.MY_PROJECT进行测试。