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

environment variables undefined #50

Open
matthewboman opened this issue Jan 23, 2019 · 7 comments
Open

environment variables undefined #50

matthewboman opened this issue Jan 23, 2019 · 7 comments
Labels

Comments

@matthewboman
Copy link

When I try to start the site (~p. 248), I'm met with the following error:

Unhandled rejection SequelizeConnectionError: password authentication failed for user "crash"

which caught me off guard because my .env file is:

DATABASE=gql
DATABASE_USER=postgres
DATABASE_PASSWORD=postgres

After going down the rabbit hole with Postgres and permissions and still not solving the issue I tried logging my environment variables only to find them undefined. (Really, that should have been the first place I checked).

I was able to fix the issue by updating /models/index.js and adding:

import 'dotenv/config';

I see it also exists in /src/index.js in the repo, but the book never specifies adding it anywhere. Updating the code for the index on p. 243 would save the reader a lot of troubleshooting.

@rwieruch
Copy link
Member

Hi @crashspringfield Thanks for reporting this. It's mentioned over here https://www.robinwieruch.de/minimal-node-js-babel-setup/ with the order of importing as well. But you are right, maybe it should be mentioned again for environment variables. It's too easy to run into an error with them. Sorry again!

@jakec-dev
Copy link

I'm getting the same issue but adding that import to /models/index.js didn't solve it for me. I followed the steps listed in the readme, no other changes made, and get the following error:

Unhandled rejection SequelizeConnectionError: password authentication failed for user "root"

@jakec-dev
Copy link

Nevermind, I totally forgot that .env is ignored by git so I need to recreate it after pulling from my local repo. It's all good, working now.

@rwieruch
Copy link
Member

rwieruch commented Apr 5, 2019

@rwieruch
Copy link
Member

rwieruch commented Apr 5, 2019

Finally added over here: the-road-to-graphql/the-road-to-graphql@643356c I keep this issue open for people with the old version of the book though.

@rwieruch
Copy link
Member

Anyone who runs into this issue and finds this issue, please comment. If I find no comment here the next time I get to this issue, I will close it :)

@rwieruch rwieruch added the Fixed label May 14, 2019
@krynv
Copy link

krynv commented Sep 5, 2019

Had same issue, OP helped solve it.

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

No branches or pull requests

4 participants