Closed Pardeep9stacks closed 3 years ago
Which version of the library are you using? It shouldn't throw on importing, even in a node environment.
It might throw if you try and use it. In which case feature-detect it with something like if (self.indexedDB)
I'm experiencing the same issue with Nuxt. I'm using IDB 4.0.3
The error specifically mentions the file node_modules\idb\build\cjs\index.js on line 15
const request = indexedDB.open(name, version);
FWIW, I ended up using regular IndexedDB but wrapping that component in Nuxt <no-ssr></no-ssr>
tags.
@jakearchibald I am using IDB v3.0.2. Facing this issue while using with Angular Universal.
Could someone create a minimal reproducible example of the problem for me to debug?
@jakearchibald This issue happens when I try to build my project in SSR ( Angular Universal ). Then I solve it by adding this condition in ts file:
isBrowser;
constructor(@Inject(PLATFORM_ID) private platformId) {
this.isBrowser = isPlatformBrowser(platformId);
}
if (this.isBrowser) {
// put your code which is access window variable
}
Check this out: https://github.com/angular/universal/issues/830
Closing this. Happy to look at it if a minimal example can be provided. A minimal example includes only the things needed to recreate the issue, and has instructions for how to recreate the issue.
Trying to use this package with Angular universal but facing this issue.
ReferenceError: IDBIndex is not defined
Probably this is not working on server, Can someone provide a possible workaround for this? Do I need to
import { openDb, deleteDb } from 'idb';
conditionally? or something else.