I am unable to get Sveltekit to read the latest values from .env.
Any help on where are these old values coming from?
I have tried the following ways:
1.
import { SALESFORCE_CLIENT_SECRET, SALESFORCE_CLIENT_ID, SALESFORCE_CALLBACK_URI_BASE } from '$env/static/private'
import { env } from '$env/dynamic/private'
console.log('meta.env.DEV-->', import.meta.env.DEV.valueOf());
console.log('settings-static-->', SALESFORCE_CALLBACK_URI_BASE)
console.log('settings-dynamic-->', env.SALESFORCE_CALLBACK_URI_BASE)
console.log('settings-process.env->', process.env.SALESFORCE_CALLBACK_URI_BASE)
They all show the "old value"
I entered
nodeand explicitly set theprocess.env.SALESFORCE_CALLBACK_URI_BASEto a new value, but when I rannpm run devthis value was overwritten.I explicitly installed
dotenvpackage.My
.envfile is at the base of the project and I also created a second.env.localwith the correct values.I restarted my VSCode.
In
svelte.config.jsI addedenvproperty.
const config = {
preprocess: vitePreprocess(),
kit: {
env: {
dir: '.',
},
adapter: adapter()
}
};
- Deleted
.svelte-kit/andnode_modules/.viteand usednpm run dev.
The above steps were done exclusive of each other and they did not work.
I realized that the values were being persisted in my bash
env.You can print it by typing this in the terminal
From this GH comment to "Show environment contributions" for my VSCode integrated zsh terminal, I checked that the
ms-python.pythonVSCode extension had an Activated environment for~/.pyenv/versions/3.10.2/bin/pythonwhich was bringing those values. (Maybe from an earlier project? I am not sure where they came from.)so I used this SO answer to unset those "old values".
After this svelte read my values correctly. Still a bit weird why in a TS/JS project were python interpreter values being interfering.