Skip to content

Instantly share code, notes, and snippets.

@leongaban
Created June 12, 2017 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leongaban/dc92204454b3513e511645af98107775 to your computer and use it in GitHub Desktop.
Save leongaban/dc92204454b3513e511645af98107775 to your computer and use it in GitHub Desktop.
Get environment variable into node and create a js file
const environment = process.env.NODE_ENV;
const stream = fs.createWriteStream("src/services/environment.js");
stream.once('open', function(fd) {
stream.write('const env = "'+environment+'"\n');
stream.write('export default env');
stream.end();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment