수

환경설정 - dotenv

· 2019-02-07 (목) 19:18:01 · 3209

dotenv

 

Dotenv는 .env파일 에서 환경 변수를로드하는 제로 의존성 모듈입니다 

process.env. 코드와 별도의 환경에 구성을 저장하는 것은 The Twelve-Factor App 방법론을 기반으로 합니다.

 

 

Install

# with npm 

npm install dotenv

 

# or with Yarn 

yarn add dotenv

 

사용방법

require('dotenv').config()

 

.env프로젝트의 루트 디렉토리에 파일을 만듭니다 . 

새 행에 환경 특정 변수를의 형태로 추가하십시오 

형식 NAME=VALUE

 

DB_HOST = 로컬 호스트

DB_USER = 루트

DB_PASS = s1mpl3

 

========================================

const db = require('db')

require('dotenv').config()

 

db.connect({

  host: process.env.DB_HOST,

  username: process.env.DB_USER,

  password: process.env.DB_PASS

})

 

 

 

|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
PHP 19-06-24 조회 3,189
PHP 19-06-09 조회 3,810
MySQL 19-04-01 조회 4,863
jQuery 19-03-20 조회 4,248
node.js 19-02-12 조회 3,351
node.js 19-02-12 조회 3,083
node.js 19-02-12 조회 3,347
node.js 19-02-07 조회 3,325
node.js 19-02-07 조회 3,063
node.js 19-02-07 조회 3,210
node.js 19-02-04 조회 2,947
node.js 19-02-04 조회 2,921
node.js 19-02-04 조회 3,368
node.js 19-01-31 조회 2,477
node.js 19-01-31 조회 2,627
node.js 19-01-31 조회 3,106
node.js 19-01-28 조회 2,868
node.js 19-01-28 조회 2,951
node.js 19-01-28 조회 2,792
node.js 19-01-22 조회 3,121
node.js 19-01-22 조회 2,885
node.js 19-01-22 조회 3,309
node.js 19-01-16 조회 2,754
node.js
[node.js]
19-01-16 조회 2,647
node.js 19-01-16 조회 9,325
node.js 19-01-12 조회 4,403
node.js 19-01-12 조회 3,001
node.js 19-01-12 조회 3,152
node.js 19-01-11 조회 2,696
node.js 19-01-11 조회 4,050