jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.29k stars 353 forks source link

Can not import in webpack project #187

Closed iSuslov closed 3 years ago

iSuslov commented 4 years ago

Trying to import idb like this: import { openDB, deleteDB, wrap, unwrap } from 'idb';

Getting this error.

idb.js:1 Uncaught Error: Module build failed: Error: ENOENT: no such file or directory, open '/Users/User/project/node_modules/idb/build/idb.js'
    at eval (idb.js:1)
    at Object../node_modules/idb/build/idb.js (main.js:2344)
    at __webpack_require__ (main.js:770)
    at fn (main.js:130)
    at eval (the-app.js:2)
    at Module../src/the-app.js (main.js:4235)
    at __webpack_require__ (main.js:770)
    at fn (main.js:130)
    at eval (webpack:///multi_(:8080/webpack)-dev-server/client?:3:18)
    at Object.0 (main.js:4257)
eval @ idb.js:1
./node_modules/idb/build/idb.js @ main.js:2344
__webpack_require__ @ main.js:770
fn @ main.js:130
eval @ the-app.js:2
./src/the-app.js @ main.js:4235
__webpack_require__ @ main.js:770
fn @ main.js:130
eval @ client:3
0 @ main.js:4257
__webpack_require__ @ main.js:770
(anonymous) @ main.js:908
(anonymous) @ main.js:911
client:48 [WDS] Hot Module Replacement enabled.
client:52 [WDS] Live Reloading enabled.
client:150 [WDS] Errors while compiling. Reload prevented.
errors @ client:150
eval @ socket.js:47
sock.onmessage @ SockJSClient.js:63
EventTarget.dispatchEvent @ sockjs.js:170
eval @ sockjs.js:887
SockJS._transportMessage @ sockjs.js:885
EventEmitter.emit @ sockjs.js:86
WebSocketTransport.ws.onmessage @ sockjs.js:2961
client:159 ./node_modules/idb/build/idb.js
Module build failed: Error: ENOENT: no such file or directory, open '/Users/User/project/node_modules/idb/build/idb.js'

I'm using v5.0.3

bochap commented 3 years ago

Do you have a repo somewhere that can be accessed publicly? It might be easier to look at some code. Although the file path "...../node_modules/idb/build/idb.js" being reference does not look correct at first glance.

jakearchibald commented 3 years ago

https://github.com/jakearchibald/idb-minimal-webpack here's an example of it working. Please open an issue with reproducible steps if there's a bug.