Question

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!

Était-ce utile?

La solution

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

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top