'Cant resolve ipfs-car/blockstore/memory when importing nft.storage
Im trying to store my nft metadata to ipfs using nft.storage (Reactjs) When I import the library as explained in their docs I get this error enter image description here
I read a similar error online for web3storage library and that it is probably a webpack version issue, but there is no solution. Any ideas? This is how I am importing it: import { NFTStorage, File } from 'nft.storage'
Exactly as shown in the docs.
Solution 1:[1]
Since there's insufficient info on how to deal with this out of the box, this is how I resolved it. It worked fine.
- Go to
node_modules/nft.storagedirectory. - Make sure you have
ipfs-car/dist/esm/blockstoreandipfs-car/dist/esm/pack. If not, install ipfs-car withnpm i ipfs-car. Copyipfs-car/dist/esmtonft.storage/src. - Inside
nft.storage/src, update theipfs-carimport statements in the following files like so:
Inside platform.web.js, update to this: import { MemoryBlockStore } from 'ipfs-car/dist/esm/blockstore/memory'
Inside lib.js, update to this: import { pack } from 'ipfs-car/dist/esm/pack'
Inside token.js, update to this: import { pack } from 'ipfs-car/dist/esm/pack'
This solved my problem.
Crude but works.
Solution 2:[2]
importing pack from built version should also work but crude as well...the package doesn't work at all without doing these, they should update it...I will send a pull request later on.
import { Web3Storage } from 'web3.storage/dist/bundle.esm.min.js'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | George |
| Solution 2 | Caner |
