I have encountered an issue with my SvelteKit project which uses TypeScript and includes a .env
file at the root. Additionally, I have added a drizzle.config.ts
file at the root directory. The problem arises when I try to import DATABASE_HOST
from $env/static/private
in the following line:
import { DATABASE_HOST } from '$env/static/private';
Both WebStorm and VSCode display an error message stating:
Cannot find module '$env/static/private' or its corresponding type declarations.
This issue persists even in new SvelteKit projects where the same files are added as mentioned above. Restarting VSCode, Webstorm, and my computer has not resolved the problem. I have also attempted starting a fresh project but still encountered the error. I have come across suggestions to alter configuration files, however, these solutions did not work for me. It seems there should be a straightforward way to handle this without requiring such modifications.
If anyone could shed light on why this is happening and provide guidance on the correct approach to utilizing Environment variables in root files within SvelteKit, it would be greatly appreciated!
Thank you in advance!