title: Node.js - how to set environment variables in code
body: <p>I am fairly new to node.js, and have a program that I have to set an environment variable in order to run (using the <a href="https://github.com/sandeepmistry/noble" rel="noreferrer">noble</a> library, my bash command is: <code>sudo NOBLE_HCI_DEVICE_ID=x node program.js</code>, to tell my code which Bluetooth adapter - HCI device - to use).</p>
  
  <p>The reason behind this is that I have a number of modules, each needing their own Bluetooth adapter, and I wish to specify in my code which adapter each module should use. </p>
  
  <p>I've found lots of articles telling me how to consume environment variables in my code and set them via the command line (process.env.VARIABLE_NAME), but nothing telling me how to set them from within node.js. </p>
  
  <p>Is it possible to set the environment variables in my node.js code?</p>