zoukankan      html  css  js  c++  java
  • xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

    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 =
    `, process.env)
    log(`process.env.GITHUB_API_ACCESS_TOKEN =
    `, 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=
    

    临时环境变量

    1. Linux / macOS
    # 设置 NODE_ENV 环境变量
    $ export NODE_ENV=production
    
    # 清除 NODE_ENV 环境变量
    $ export NODE_ENV=
    
    1. Windows
    # 设置 NODE_ENV 环境变量
    $ set NODE_ENV=production
    
    # 清除 NODE_ENV 环境变量
    $ set NODE_ENV=
    

    永久环境变量(⚠️ 不推荐,不够灵活)

    修改系统的配置文件 $PATH

    1. vim
    2. VS Code
    3. 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


    Flag Counter

    ©xgqfrms 2012-2020

    www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


  • 相关阅读:
    LSTM
    Realsense D435i
    ubuntu18 realsenseD435i
    net
    test
    LSTM Accuracy
    boost x64 lib
    E0443类模板 "std::unordered_set" 的参数太多
    PropertySheet
    freetype 编译
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/13501449.html
Copyright © 2011-2022 走看看