how to config custom process.env in node.js
how to config custom process.env in node.js
process.env
APP_ENV
NODE_ENV

https://nodejs.org/api/process.html#process_process_env
GITHUB_API_ACCESS_TOKEN
#!/usr/bin/env node
"use strict";
/**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
* @created 2020-08-0
* @modified
*
* @description
* @difficulty Easy Medium Hard
* @complexity O(n)
* @augments
* @example
* @link https://www.cnblogs.com/xgqfrms/p/13500721.html#4658099
* @solutions
*
*/
const log = console.log;
log(`process.env =\n`, process.env)
log(`process.env.GITHUB_API_ACCESS_TOKEN =\n`, process.env.GITHUB_API_ACCESS_TOKEN)
// const access_token = process.env.GITHUB_API_ACCESS_TOKEN;
btoa(`process.env.GITHUB_API_ACCESS_TOKEN`)
// "cHJvY2Vzcy5lbnYuR0lUSFVCX0FQSV9BQ0NFU1NfVE9LRU4="
# bin cli
$ chmod +x ./env.js
# OR
$ chmod 777 ./env.js
$ export GITHUB_API_ACCESS_TOKEN=cHJvY2Vzcy5lbnYuR0lUSFVCX0FQSV9BQ0NFU1NfVE9LRU4= && ./env.js
# Linux / macOS, using export command
$ export GITHUB_API_ACCESS_TOKEN=cHJvY2Vzcy5lbnYuR0lUSFVCX0FQSV9BQ0NFU1NfVE9LRU4=
# Windows, using set command
$ set GITHUB_API_ACCESS_TOKEN=cHJvY2Vzcy5lbnYuR0lUSFVCX0FQSV9BQ0NFU1NfVE9LRU4=
临时环境变量
- Linux / macOS
# 设置 NODE_ENV 环境变量
$ export NODE_ENV=production
# 清除 NODE_ENV 环境变量
$ export NODE_ENV=
- Windows
# 设置 NODE_ENV 环境变量
$ set NODE_ENV=production
# 清除 NODE_ENV 环境变量
$ set NODE_ENV=
永久环境变量(️ 不推荐,不够灵活)
修改系统的配置文件 $PATH
- vim
- VS Code
- GUI
# 当前用户
$ vim ~/.zshrc
# OR
$ vim ~/.bash_profile
# 在文件进行环境变量的设置或修改
# export NODE_ENV_PROD = production
# export NODE_ENV_DEV = development
# 修改后,需要刷新
$ source ~/.zshrc
# OR
$ source ~/.bash_profile
Flutter & Dart
github-user-language-stats bug
# cli
$ npm i -g github-user-language-stats
# process.env.GITHUB_API_ACCESS_TOKEN
$ export GITHUB_API_ACCESS_TOKEN=<your token> && gh-lang-stat <github username>
# demo
$ export GITHUB_API_ACCESS_TOKEN=cHJvY2Vzcy5lbnYuR0lUSFVCX0FQSV9BQ0NFU1NfVE9LRU4= && gh-lang-stat xgqfrms
refs
https://www.cnblogs.com/xgqfrms/p/13500721.html#4658099
https://nodejs.org/api/process.html#process_process_env
https://github.com/kentcdodds/cross-env
https://www.cnblogs.com/sorex/p/6200940.html
https://segmentfault.com/a/1190000011683741
https://github.com/xgqfrms/2020-interview-notes/blob/master/test/env.js
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
how to config custom process.env in node.js的更多相关文章
- 极简 Node.js 入门 - 2.3 process
极简 Node.js 入门系列教程:https://www.yuque.com/sunluyong/node 本文更佳阅读体验:https://www.yuque.com/sunluyong/node ...
- [Node.js] 06 - Multi-thread and process module
课前阅读:关于Node.js后端架构的一点后知后觉 书推荐:<Node.js design patterns> 衍生问题: 微服务的必要性,Flux架构 容错性和拓展性 一.立体拓展 假设 ...
- Node.JS学习——学习笔记
Node.JS--学习笔记 2020年02月23日11:52:01 我打算自学NodeJS-通过阅读NodeJS官网来完成. https://nodejs.org/dist/latest-v13.x/ ...
- 深入理解 Node.js 进程与线程
原文链接: https://mp.weixin.qq.com/s?__biz=MzAxODE2MjM1MA==&mid=2651557398&idx=1&sn=1fb991da ...
- Node.js的net模块
net模块提供了一个异步网络包装器,用于TCP网络编程,它包含了创建服务器和客户端的方法 创建TCP服务器 net.createServer方法 创建客户端去连接服务器 net.connect方法 简 ...
- [Server Running] [Node.js, PM2] Using PM2 To Keep Your Node Apps Alive
PM2 is a production process manager for Node.js applications with a built-in load balancer. It allow ...
- Node.js学习笔记(四): 全局对象
在浏览器 JavaScript 中,通常 window 是全局对象, 而 Node.js 中的全局对象是 global,所有全局变量(除了 global 本身以外)都是 global 对象的属性. 这 ...
- node.js 运行机制与简单使用
一.hello world 1.引入 required 模块 2.创建服务器 3.接收请求与响应请求 var http = require('http'); // 载入http模块 http.crea ...
- Practical Node.js摘录(2018版)第1,2章。
大神的node书,免费 视频:https://node.university/courses/short-lectures/lectures/3949510 另一本书:全栈JavaScript,学习b ...
随机推荐
- is_callable Callbacks / Callables What is a “callable”? 可调用 回调函数
PHP: Callback / Callable 类型 - Manual https://www.php.net/manual/zh/language.types.callable.php Callb ...
- xftp 提示无法显示远程文件夹
在用xftp远程服务器,打开文件夹的时候一直提示"无法显示远程文件夹" 解决方案: 1.网上大多解决方案是文件->属性->选项->将使用被动模式选项去掉即可 2. ...
- Java 学习之路 -- day00
Java 学习之路 -- day00 Typora 快捷键操作 标题:#+空格 2. *斜体* 3. **加粗** 4. **斜体加粗*** 5. ~~删除线~~ 6. > 引用 7. ···分 ...
- 某商城系统(V1.3-2020-01-10)前台命令执行漏洞
漏洞文件: ./inc/module/upload_img.php 先跟进 del_file 函数: 在 del_file 函数中首先执行了unlink操作,然后接着进行了file_exists 判断 ...
- Windows搭建TestLink环境
环境准备: 搭建php5.4.39+apache2.2+mysq5.5.28l环境 (可参考http://www.cnblogs.com/yangxia-test/p/4414161.html) (注 ...
- java架构《Socket网络编程基础篇》
本章主要介绍Socket的基本概念,传统的同步阻塞式I/O编程,伪异步IO实现,学习NIO的同步非阻塞编程和NIO2.0(AIO)异步非阻塞编程. 目前为止,Java共支持3种网络编程模型:BIO.N ...
- Spring Boot 两种多数据源配置:JdbcTemplate、Spring-data-jpa
多数据源配置 JdbcTemplate支持 Spring-data-jpa支持 多数据源配置 创建一个Spring配置类,定义两个DataSource用来读取application.propertie ...
- Spring boot AOP 记录请求日志
如何将所有的通过url的请求参数以及返回结果都输出到日志中? 如果在controller的类中每个方法名都写一个log输出肯定是不明智的选择. 使用spring的AOP功能即可完成. 1. 在pom. ...
- java日期
// 完整显示日期时间 String str = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS")).format(new Date ...
- mysql-mysqli_fetch_all(错误)
mysql-mysqli_fetch_all(错误) 问题:使用mysql-mysqli_fetch_all获取返回的数组时失败/报错 原因及解决方法: mysqli_fetch_all函数只存在于m ...