Search code examples
parceljs

Parcel not finding .env variables


I have a simple setup, .env file at the same level as my package.json with:

API_URL=http://localhost:8080

Then, in my js I've written something like:

console.log(process.env);
// {}

I've tried deleting my .cache but no dice. I'm looking at their docs about env variables, and saw something about parcel-builder should be in the package.json so I added that as a long shot, but that didn't work either.


Solution

  • Seems you figured it out. For other people with the same question:

    The full process.env object is not accessible for security reasons, but individual properties like process.env.API_URL should work.