node dotenv
$ npm install dotenv
//--------------------
on file .env
//--------------------
DB_HOST=localhost
DB_USER=root
DB_PASS=s1mpl3
DB_NAME=banco_de_dados
DB_PORT=3306
//--------------------
import the config from .env file
//--------------------
require('dotenv').config()
module.exports = {
username:process.env.DB_USER,
password:process.env.DB_PASS,
database:process.env.DB_NAME,
host:process.env.DB_HOST,
dialect:"mysql"
}
require('dotenv').config();
console.log(process.env.MY_ENV_VAR);require('dotenv').config()npm install dotenvRename your file to just .env, removing any prefix
require it as early as possible in your application with the code snippet below
require('dotenv').config();
Also in JavaScript:
- react native text input number only
- replace innerhtml javascript by regex
- search bar in react js example
- camelcase to hyphenated javascript
- jquery toggle text on click
- how to check is the key of a localstorage is emopty
- unix timestamp to date javascript yyyy-mm-dd
- react.createref()
- 00:00:00 / 00:00:00 js
- javascript url check
- change width in js
- Did you mean to use React.forwardRef()?
- enzyme test method
- js how to add element in object
- javascript variable with multiline text
- set a value in session using javascript
- render image url in react native
- javascript on the fly form submit
- closure javascript
- getElementbyhref
- switch in react
- delete local storage javascript
- on reload js
- react router last page