문제

I want to set an environment variable using setenv:

setenv NODE_ENV localhost  

But setenv gives me an error saying the command is not found. Does anyone know how to perform the MAC OSX equivalent of setenv? Thanks!

도움이 되었습니까?

해결책

you want export

NODE_ENV=localhost
export NODE_ENV

or on 1 line export NODE_ENV=localhost

and this has nothing to do with OSX per se, more to do with bash vs (t)csh as your shell

다른 팁

Best for Mac is:

launchctl setenv NODE_ENV localhost

if you want to make the variable persistent and avoid rebooting.

See:

http://www.dowdandassociates.com/blog/content/howto-set-an-environment-variable-in-mac-os-x-slash-etc-slash-launchd-dot-conf/

Are you a Cshell person?

The earlier versions of OS X came with tcsh as the default shell since OS X is based upon BSD. However, Mac OS X comes with BASH as the user's default shell.

Macs still come with Turbo Csh too and you can make this your default shell if that is your desire. In the terminal, type:

$ chsh -s /bin/tcsh

If you decide you want switch back to BASH:

$ chsh -s /bin/bash

You can see a list of all possible shells in the /etc/shell file.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top