diff --git a/src/index.ts b/src/index.ts index ee5e9a1..e6bc7a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,7 +25,9 @@ const html2canvas = (element: HTMLElement, options: Partial = {}): Prom export default html2canvas; -CacheStorage.setContext(window); +if (typeof window !== "undefined") { + CacheStorage.setContext(window); +} const renderElement = async (element: HTMLElement, opts: Partial): Promise => { const ownerDocument = element.ownerDocument;