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.
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.storage
directory. - Make sure you have
ipfs-car/dist/esm/blockstore
andipfs-car/dist/esm/pack
. If not, install ipfs-car withnpm i ipfs-car
. Copyipfs-car/dist/esm
tonft.storage/src
. - Inside
nft.storage/src
, update theipfs-car
import 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.