Parcel uses dotenv to support loading environment variables from
.env files are to be stored alongside the
package.json that contains your
.env files with these specific names for the following
.env.localis not loaded when
NODE_ENV=testsince tests should produce the same results for everyone
- Sometimes introducing a new .env file will not work immediately. Try deleting the .cache/ directory in this case.
- Accessing the
process.envobject directly is not supported, but accessing specific variables on it like
process.env.API_KEYwill provide the expected value.
- Use the built-in
processNode.js global, i.e. don't do
import process from "process", because it will not work. If you use TypeScript, you probably want to install
@types/nodefor it to compile.