title: How to export env variable in node.js
body: <p>I like my <code>node.js</code> so much, that I want to use it is my <code>bash</code> start up script <code>~/.bashrc</code>, but I do not know how to export variable.</p>
  
  <p>Currently I have to use this approach:</p>
  
  <pre><code>export PS1=`node ~/PS1.js`
  export PS2=`node ~/PS2.js`
  export PATH=`node ~/PATH.js`
  </code></pre>
  
  <p>instead I want <code>.bashrc</code> look have</p>
  
  <pre><code>#!/usr/local/bin/node
  //do something, define functions
  export_var('PS1', PS1())
  export_var('PS2', PS2())
  export_var('PATH', generatePATH())
  </code></pre>
  
  <p><code>process.env.PATH = something</code> does not <em>export</em>, only sets for the currently executing process, which is node itself.</p>