yhnavein / express-starter

It's a hackathon-starter fork, but designed to use PostgreSQL by default (or MySQL)
MIT License
209 stars 53 forks source link

no such file or directory, open '.env' #8

Open pavankat opened 6 years ago

pavankat commented 6 years ago

I updated the secrets file with my postgres credentials.

However, I get a warning when starting up the app. Any ideas? It works.

{ Error: ENOENT: no such file or directory, open '.env'
    at Object.fs.openSync (fs.js:583:18)
    at Object.fs.readFileSync (fs.js:490:33)
    at Object.config (/Users/pavankatepalli/Desktop/git/node/mine/cryptofigure/node_modules/dotenv/lib/main.js:30:37)
    at Object.<anonymous> (/Users/pavankatepalli/Desktop/git/node/mine/cryptofigure/app.js:7:19)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10) errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' }
Rob-Rychs commented 6 years ago

Hey @pavankat just rename the file sample.env in the repo to .env and you can include your secrets in there...

Quick question for you, if you added postgres to the config/secrets.js how did you get your URL? to replace for example 'postgres://yhnavein:123@127.0.0.1/prod'; on line 143 in config/secrets.js

Could you also explain anywhere else you added postgres credentials?

Thanks! 😀

is this URL mean postgres://user:password@localhost/db_name? clearly no local user yhnavein, sorry not the best with postgres + sequelize! image

Rob-Rychs commented 6 years ago

Got this all working fine now. If the db gives anyone else trouble at first just change the 'postgres://yhnavein:123@127.0.0.1/prod'; to 'postgres://@localhost:5432/prod' for running local in dev and then run createdb prod, start postgreSQL servers and you can connect to the db on port 5432