opensea-creatures icon indicating copy to clipboard operation
opensea-creatures copied to clipboard

Environment variable is undefined

Open orangeagain opened this issue 2 years ago • 1 comments

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

orangeagain avatar Apr 17 '22 16:04 orangeagain

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

asghar2016 avatar May 07 '22 04:05 asghar2016