toddbluhm / env-cmd

Setting environment variables from a file
https://www.npmjs.com/package/env-cmd
MIT License
1.73k stars 65 forks source link

.env-cmdrc syntax error but prompts 'Error: Failed to find .rc file at default paths' #354

Open xiangnanscu opened 1 year ago

xiangnanscu commented 1 year ago
    This confused me because I thought env-cmd couldn't find my configuration file, since that was the only error I saw. It turned out it was an error in my configuration code causing the issue. I'd definitely suggest outputting any errors to the console.

Originally posted by @alflennik in https://github.com/toddbluhm/env-cmd/issues/127#issuecomment-879333280

xiangnanscu commented 1 year ago

for example, you place some invalid content in .env-cmdrc like this:

{"base":{"num": 20 * 3 * 40}}

and you run env-cmd -e base echo bla, it says Error: Failed to find .rc file at default paths: [./.env-cmdrc,./.env-cmdrc.js,./.env-cmdrc.json], but in fact the file exists, its content is just invalid