svelte-cloudinary icon indicating copy to clipboard operation
svelte-cloudinary copied to clipboard

TypeError: __vite_ssr_import_11__.initialize is not a function on SvelteKit & fix

Open freeform99 opened this issue 3 years ago • 0 comments

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?

freeform99 avatar Mar 31 '22 20:03 freeform99