Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

How to catch error if .env file not found in Svelte?

$
0
0

Let's say I import an .env variable using

import { PUBLIC_URL } from '$env/static/public';

If the variable does not exists, it will throw an HTTP 500 Internal Server error and I can read the error in the console.

Now if someone else clones the repository and does not have an .env file, I would like to catch this error message and throw a decent error description.

How can I achieve this?

I tried using fs.exists(), but it seems that I am unable to use fs in Svelte. I also tried importing dotenv and running config. It gives an error process is not defined, when the file does exist.


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>