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.

  1. Go to node_modules/nft.storage directory.
  2. Make sure you have ipfs-car/dist/esm/blockstore and ipfs-car/dist/esm/pack. If not, install ipfs-car with npm i ipfs-car. Copy ipfs-car/dist/esm to nft.storage/src.
  3. Inside nft.storage/src, update the ipfs-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.