Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Unable to locate env file at default locations (./.env,./.env.js,./.env.json) [duplicate]

I am following a Gatsby tutorial and hit a road block. I tried code that were similar on Google or Stackoverflow. They did not work.

I am trying to upgrade Gatsby's default GraphQL default IDE. I added (dot),env.development variable on my root folder, With the dev server shutdown I entered npm install --save-dev env-cmd in the terminal. I then modified the develop script in package.json by entering "develop": "env-cmd .env.development gatsby develop":. I then restart the dev server, but after I run npm run develop I get the errors below. Thanks in advance.

[email protected] develop C:\Users\fanok\Desktop\myDevProjects\gatsby-first-site

env-cmd .env.development gatsby develop

Error: Unable to locate env file at default locations (./.env,./.env.js,./.env.json) at getEnvFile (C:\Users\fanok\Desktop\myDevProjects\gatsby-first-site\node_modules\env-cmd\dist\get-env-vars.js:34:11)npm

ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! [email protected] develop: env-cmd .env.development gatsby develop

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the [email protected] develop script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Users\fanok\AppData\Roaming\npm-cache_logs\2020-02-03T23_01_39_042Z-debug.log

like image 912
Jels0nB0nilla Avatar asked Dec 17 '22 14:12

Jels0nB0nilla


1 Answers

Add -f to your develop script, like:

"develop": "env-cmd -f .env.development gatsby develop"

-f stands for file and it's for passing custom file path as an argument.

like image 195
tpliakas Avatar answered Dec 31 '22 02:12

tpliakas