How to use the env function from process
Find comprehensive JavaScript process.env code examples handpicked from public code repositorys.
process.env is a Node.js global object that contains information about the environment in which the current process is running, including things like operating system, user data, and custom environment variables.
GitHub: getsentry/sentry-cli
![getsentry profile picture](/getsentry.png?size=40)
21 22 23 24 25 26 27 28 29
const Logger = require('../js/logger'); const logger = new Logger(getLogStream('stderr')); const CDN_URL = process.env.SENTRYCLI_LOCAL_CDNURL || process.env.npm_config_sentrycli_cdnurl || process.env.SENTRYCLI_CDNURL || 'https://downloads.sentry-cdn.com/sentry-cli';
+ 13 other calls in file
9 10 11 12 13 14 15 16 17 18
// 指定日期 var startDate = '2017-06-20'; var endDate = '2017-06-22'; var granularity = 'day'; var accessKey = proc.env.QINIU_ACCESS_KEY; var secretKey = proc.env.QINIU_SECRET_KEY; var mac = new qiniu.auth.digest.Mac(accessKey, secretKey); var cdnManager = new qiniu.cdn.CdnManager(mac); // 获取域名带宽
+ 7 other calls in file
How does process.env work?
process.env is a property of the Node.js process object that provides access to the environment variables that were set when the Node.js process was started. It is an object containing key-value pairs representing the current user environment.
GitHub: qiniu/nodejs-sdk
12 13 14 15 16 17 18 19 20 21 22
}); describe('test util functions', function () { var accessKey = proc.env.QINIU_ACCESS_KEY; var secretKey = proc.env.QINIU_SECRET_KEY; var bucket = proc.env.QINIU_TEST_BUCKET; var mac = new qiniu.auth.digest.Mac(accessKey, secretKey); var config = new qiniu.conf.Config(); var bucketManager = new qiniu.rs.BucketManager(mac, config);
+ 8 other calls in file
GitHub: ForumMagnum/ForumMagnum
![ForumMagnum profile picture](/ForumMagnum.png?size=40)
54 55 56 57 58 59 60 61 62
if (databaseConfig.sshTunnelCommand) { startSshTunnel(databaseConfig.sshTunnelCommand); } if (isProduction) { process.env.NODE_ENV="production"; } else { process.env.NODE_ENV="development"; }
+ 3 other calls in file
Ai Example
1 2 3 4 5
// Get the value of the NODE_ENV environment variable const env = process.env.NODE_ENV; // Print out the value of the environment variable console.log(`The value of NODE_ENV is: ${env}`);
In this example, we're using process.env to access the NODE_ENV environment variable and store its value in the env variable. We then use console.log() to print out the value of the environment variable to the console.
GitHub: eclipse/streamsheets
![eclipse profile picture](/eclipse.png?size=40)
14 15 16 17 18 19 20 21 22 23
const packageJSON = require('./package.json'); const process = require('process'); const logger = LoggerFactory.createLogger( 'Stream Service', process.env.STREAMSHEETS_STREAMS_SERVICE_LOG_LEVEL ); metadata.version = packageJSON.version; process.on('unhandledRejection', (error) => {
GitHub: Cohee1207/SillyTavern
![Cohee1207 profile picture](/Cohee1207.png?size=40)
158 159 160 161 162 163 164 165 166 167
let humanMillisecond = (baseDate.getMilliseconds() < 10 ? '0' : '') + baseDate.getMilliseconds(); let HumanizedDateTime = (humanYear + "-" + humanMonth + "-" + humanDate + " @" + humanHour + "h " + humanMinute + "m " + humanSecond + "s " + humanMillisecond + "ms"); return HumanizedDateTime; }; var is_colab = process.env.colaburl !== undefined; var charactersPath = 'public/characters/'; var chatsPath = 'public/chats/'; const jsonParser = express.json({ limit: '100mb' }); const urlencodedParser = express.urlencoded({ extended: true, limit: '100mb' });
+ 3 other calls in file
142 143 144 145 146 147 148 149 150 151
mainWindow.webContents.on('new-window', function (e, url) { e.preventDefault(); shell.openExternal(url); }); const envStartUrl = isPackaged ? null : process.env.ELECTRON_START_URL const startUrl = envStartUrl || url.format({ pathname: joinPath(__dirname, '..', 'build', 'index.html'), protocol: 'file:', slashes: true
GitHub: CyberRex0/5000choyen-api
![CyberRex0 profile picture](/CyberRex0.png?size=40)
48 49 50 51 52 53 54 55 56 57
} } if (process.env.CLID) CLUSTER_ID = Number(process.env.CLID); const PORT = process.env.PORT || 8080; console.log(` *** 5000choyen API Server v${APP_VER} *** (C)2021 CyberRex
+ 11 other calls in file
5 6 7 8 9 10 11 12 13 14
const path = require('path'); const process = require('process'); const ON_DEATH = require('death')({ debug: false }); const logger = require('../src/logger')(); const env = process.env; // Honestly, not sure what this is. Took it from the seed project function envOrArg(name, defaultValue) { let lc = name.toLowerCase(); let uc = name.toUpperCase();
+ 3 other calls in file
21 22 23 24 25 26 27 28 29 30
if (args.length === 0 || (!args[0] && !process.env.PUBLIC_DOMAIN)) { console.error(usage); process.exit(-1); } const publicDomain = args[0] || process.env.PUBLIC_DOMAIN; updateManifests(publicDomain); } function updateManifests(publicDomain) {
GitHub: asapach/peerflix-server
![asapach profile picture](/asapach.png?size=40)
15 16 17 18 19 20 21 22 23 24
.use(serveStatic(path.join(__dirname, '../.tmp'), STATIC_OPTIONS)) .use(serveStatic(path.join(__dirname, '../app'), STATIC_OPTIONS)); var server = http.createServer(api); socket(server); var port = process.env.PORT || 9000; server.listen(port).on('error', function (e) { if (e.code !== 'EADDRINUSE' && e.code !== 'EACCES') { throw e;
+ 11 other calls in file
GitHub: im3x/GeekBot
![im3x profile picture](/im3x.png?size=40)
7 8 9 10 11 12 13 14 15 16
const process = require('process'); class Plugin extends Bot { constructor () { super(); const { caiyun_key, caiyun_gps } = process.env; if (!caiyun_key || !caiyun_gps) { console.error('! 请先配置secrets:caiyun_gps,caiyun_key'); return this.exit(); }
4 5 6 7 8 9 10 11 12
* @readonly */ exports.URL_GREP = /^https:\/\/github\.com\/([\w\-]+)\/([\w\-\.]+)\/issues\/?$/ exports.CLIENT_ID = process.env.CLIENT_ID exports.CLIENT_SECRET = process.env.CLIENT_SECRET exports.GITHUB_API = 'https://api.github.com' exports.SELF_DOMAIN = 'rss.mrcodex.com'
+ 3 other calls in file
25 26 27 28 29 30 31 32 33 34
console.log('***************************************************************************') console.log('Open Digital Architecture - Component Test Kit CTK Level 2 Dynamic Tests') console.log('***************************************************************************') console.log() const NAMESPACE = process.env.NAMESPACE const HEADER = process.env.HEADER const components = process.env.components.split(',') for (const index in components) { const componentEnvelopeName = components[index]
+ 5 other calls in file
25 26 27 28 29 30 31 32 33 34
if (process.env.LT_USERNAME) { console.log( "Setting user name from environment", process.env.LT_USERNAME ); lt_config["lambdatest_auth"]["username"] = process.env.LT_USERNAME; } } else if ( process.env.LT_USERNAME && (!("lambdatest_auth" in lt_config) ||
+ 15 other calls in file
GitHub: w3c/sparql-query
![w3c profile picture](/w3c.png?size=40)
7 8 9 10 11 12 13 14 15 16
const https = require('https'); const process = require('process'); const APIKEY = process.env.APIKEY || process.argv[2]; const GROUP = process.env.GROUP || process.argv[3] || "wg/rdf-star"; if (!APIKEY) { console.error('Error: APIKEY must be specified as either an environment variable or a command-line argument.');
+ 3 other calls in file
182 183 184 185 186 187 188 189 190 191
I've chosen to use [`autocannon`][autocannon] so I needed to write a request generation script which looks like this: ```javascript const process = require('process') const POST_COUNT = process.env.TEST_POST_COUNT ? parseInt(process.env.TEST_POST_COUNT, 10) : undefined const USER_COUNT = process.env.TEST_USER_COUNT ? parseInt(process.env.TEST_USER_COUNT, 10)
+ 7 other calls in file
GitHub: fibjs/fibjs
62 63 64 65 66 67 68 69 70 71
describe("access process.std[xx]", () => { const child_process = require('child_process'); const io = require('io'); const os = require('os'); process.env.CI && it("test process.stdout in this proc", () => { // access it process.stdout; const LEN = 100
2 3 4 5 6 7 8 9 10 11 12
const fs = require('fs'); const readline = require('readline'); const CommonUtils = require("./CommonUtils") const appSpecificErrors = require('./appSpecificErrors'); const process = require('process') const env = process.env let port = 0 const subscriptionBook = new Map() const virtualSubscriptionBook = new Map()
+ 6 other calls in file
process.exit is the most popular function in process (513 examples)