Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

env-cmd error failed to locate ./.env file in gatsby?

I have a file name .env.development in the root folder. I had install env-cmd as dev dependencies
when I start the server

  > npm run develop 

its give me an error

> [email protected] develop I:\learngatsby > env-cmd .env-development gatsby develop  (node:1368) UnhandledPromiseRejectionWarning: Error: Unable to locate env file at default location (./.env) at I:\learngatsby\node_modules\env-cmd\dist\get-env-vars.js:44:19 at Generator.throw (<anonymous>) at rejected (I:\learngatsby\node_modules\env-cmd\dist\get-env-vars.js:5:65) at process._tickCallback (internal/process/next_tick.js:68:7) at Function.Module.runMain (internal/modules/cjs/loader.js:757:11) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) 
(node:1368) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:1368) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 
like image 226
Krishna Kamal Avatar asked May 25 '19 05:05

Krishna Kamal


People also ask

What is env CMD?

Description. The env command allows you to display your current environment or run a specified command in a changed environment. If no flags or parameters are specified, the env command displays your current environment, showing one Name=Value pair per line.

What is .env file Javascript?

Its environment variables file. In simple term, it is a variable text file. In this file we set a variable with value and that you wouldn't want to share with anyone, purpose of file is keep as secret and secure because in . env file we store our database password, username, API key etc…


1 Answers

You can set environment variable using your own custom .env files with -f flag with env-cmd. Use this command to set env variables that are defined in custom file './config/myvar.env'.

env-cmd -f ./config/myvar.env

For more information use this link

like image 77
Ajay Yadav Avatar answered Sep 21 '22 01:09

Ajay Yadav