svelte-cloudinary
svelte-cloudinary copied to clipboard
TypeError: __vite_ssr_import_11__.initialize is not a function on SvelteKit & fix
Hi there,
I tried to follow the docs (I'm using SvelteKit) but received the following error:
TypeError: __vite_ssr_import_11__.initialize is not a function
at eval (/src/routes/__layout.svelte:80:25)
I fixed it by wrapping the initialization in a browser check. So instead of
initialize({ cloud_name: 'my-cloud-name' });
I had to use
import { browser } from '$app/env';
if (browser) {
initialize({ cloud_name: 'my-cloud-name' });
}
This fixed it for me.
Hope this is useful for the docs. Or should I have done something else?