开发者

process.env undefined in Node app

开发者 https://www.devze.com 2023-02-20 00:54 出处:网络
When running my Node app with node server.js, process.env returns undefined, so I\'m unable to access any environment variables. This also seems to occur when I attempt to deploy my app to Duostack.

When running my Node app with node server.js, process.env returns undefined, so I'm unable to access any environment variables. This also seems to occur when I attempt to deploy my app to Duostack.

Calling process.env from the command line seems to work, though:

$ node
> process.env
{ MANPATH: '/opt/local/share/man:',
  TERM_PROGRAM: 'Apple_Termina开发者_运维技巧l',
...

Any idea what could be going wrong?


I figured it out. process is an object (https://nodejs.org/api/process.html), but I'd defined my own function (also called process) that overwrote it. Changing the name of my function fixed the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消