opensea-creatures
opensea-creatures copied to clipboard
Environment variable is undefined
After set "INFURA_KEY" "MNEMONIC" "OWNER_ADDRESS"
and rename .env.example to .env
run yarn truffle deploy --network rinkeby
report error:
"Please set a mnemonic and ALCHEMY_KEY or INFURA_KEY."
console.log(INFURA_KEY), print undefine
I don't know which step wrong, and use "npm install dotenv --save" and add "require('dotenv').config()" to solve this problem temporary
install dotenv module ( npm i dotenv --save
)
require('dotenv').config()
//write inside the file where you will use the variable
console.log(process.env.NODE_ENV)
// returns value stored in .env file