Search code examples
javascriptnode.jsdevelopment-environment

Error: Failed to find .env file at default paths


I recently switched to using dev.env & test.env for a REST API using Javascript and I'm getting the following error:

$ npm run dev

Error:

Error: Failed to find .env file at default paths: [./.env,./.env.js,./.env.json]
    at getEnvFile 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `env-cmd ./config/dev.env nodemon src/index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Is there something I should revise in the way my .env files are stored/accessed?


Solution

  • try: env-cmd -f ./config/dev.env nodemon src/index.js