Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parcel not finding .env variables in client JS #2984

Closed
captDaylight opened this issue May 6, 2019 · 4 comments
Closed

Parcel not finding .env variables in client JS #2984

captDaylight opened this issue May 6, 2019 · 4 comments

Comments

@captDaylight
Copy link

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

API_URL=http://localhost:8080

Then, in my client app I've tried something like:

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

I've tried deleting my .cache but no dice. My parcel version is 1.12.3.

@mischnic
Copy link
Member

mischnic commented May 7, 2019

console.log(process.env);

process.env.API_URL should definitely work. I don't know if this is a bug or intended...

@DeMoorJasper
Copy link
Member

DeMoorJasper commented May 7, 2019

process.env doesn't get inlined entirely for security reasons afaik.

you should be more specific as @mischnic mentioned

So process.env.API_URL works but process.env does not

@captDaylight
Copy link
Author

Ah ok, yup that was it. I don't understand how that works, but it works.

@avalanche1
Copy link

I'd like to learn how this is realized :wow:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants