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

.env not working at all windows #2354

Closed
sethreidnz opened this issue May 24, 2017 · 2 comments
Closed

.env not working at all windows #2354

sethreidnz opened this issue May 24, 2017 · 2 comments

Comments

@sethreidnz
Copy link

sethreidnz commented May 24, 2017

Can you reproduce the problem with latest npm?

Yes I just installed Node v6.10.3 npm 3.10.10

Description

I have a file .env in the root of a brand new create-react-app that looks like this:

API_HOST=http://localhost:5000

I have added the following to the index.js file:

console.log(process.env)

I do not get anything but the default environment variables logged out:

image

Expected behavior

Expected the API_HOST variable to be available on process.env

Actual behavior

I do not get anything but the default environment variables logged out:

image

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts:

    `-- [email protected]

  2. node -v:

    v6.10.3

  3. npm -v:

    3.10.10

  4. Operating system:

    Edition: Windows 10 Enterprise
    Version: 1607
    OS Build: 14393.1198

  5. Browser and version:

    Google Chrome
    Version 58.0.3029.110 (64-bit)

Reproducible Demo

Here is the repo:

https://github.com/sethreidnz/create-react-app-dotenv-repro

The .env file I am using:

https://github.com/sethreidnz/create-react-app-dotenv-repro/blob/master/.env

The place I am trying to use the process.env:

https://github.com/sethreidnz/create-react-app-dotenv-repro/blob/master/src/index.js

This is potentially related to this issue:

#2230

@cr101
Copy link
Contributor

cr101 commented May 24, 2017

@sethreidnz It should be REACT_APP_API_HOST
Have a look at Adding Custom Environment Variables

@sethreidnz
Copy link
Author

Thank you! I did read that part but for some reason didn't think about it in the context of the .env files... Idiot!

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants