【问题标题】:How to use nft.storage library in Angular 11 project如何在 Angular 11 项目中使用 nft.storage 库
【发布时间】:2022-10-23 16:03:43
【问题描述】:

我有一个 Angular 项目,我正在尝试使用 nft.storage library。但我在 Angular Cli 中遇到以下错误:

Error: ./node_modules/nft.storage/src/platform.web.js
Module not found: Error: Can't resolve 'ipfs-car/blockstore/memory' in '/home/newsha/Newsha/sonido-project/Sonido-front/node_modules/nft.storage/src'

Error: ./node_modules/nft.storage/src/lib.js
Module not found: Error: Can't resolve 'ipfs-car/pack' in '/home/newsha/Newsha/sonido-project/Sonido-front/node_modules/nft.storage/src'

Error: ./node_modules/nft.storage/src/token.js
Module not found: Error: Can't resolve 'ipfs-car/pack' in '/home/newsha/Newsha/sonido-project/Sonido-front/node_modules/nft.storage/src'

我使用 npm 安装了该软件包,然后将其导入到项目中,如下所示:

import { NFTStorage, File } from 'nft.storage'
import { pack } from 'ipfs-car/pack';

const apiKey = 'MY_API_KEY'
const client = new NFTStorage({ token: apiKey })

【问题讨论】:

    标签: angular nft


    【解决方案1】:

    这对我有用,而不是使用

    import { NFTStorage, File } from 'nft.storage';
    

    利用

    import { NFTStorage, File } from 'nft.storage/dist/bundle.esm.min.js';
    

    参考:https://github.com/nftstorage/nft.storage/issues/876

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-05
      • 1970-01-01
      • 1970-01-01
      • 2023-03-05
      相关资源
      最近更新 更多