Reactjs Ipfs http客户端isn';我的react应用程序中没有可识别的模块

Reactjs Ipfs http客户端isn';我的react应用程序中没有可识别的模块,reactjs,npm,jsx,ipfs,Reactjs,Npm,Jsx,Ipfs,我正在尝试在我的react应用程序中使用ipfs包,但在我运行时它无法识别模块 sudo npm start 我安装模块时使用 sudo npm install -g --unsafe-perm ipfs-http-client 这将使用以下输出进行安装 > iso-constants@0.1.2 install /home/a/Documents/c/d1/dapp1/Dapp/client/node_modules/iso-constants > node build.js

我正在尝试在我的react应用程序中使用ipfs包,但在我运行时它无法识别模块

sudo npm start
我安装模块时使用

 sudo npm install -g --unsafe-perm ipfs-http-client
这将使用以下输出进行安装

> iso-constants@0.1.2 install /home/a/Documents/c/d1/dapp1/Dapp/client/node_modules/iso-constants
> node build.js > index.browser.js


> secp256k1@4.0.2 install /home/a/Documents/c/d1/dapp1/Dapp/client/node_modules/libp2p-crypto/node_modules/secp256k1
> node-gyp-build || exit 0


> ursa-optional@0.10.2 install /home/a/Documents/c/d1/dapp1/Dapp/client/node_modules/ursa-optional
> node rebuild.js


> protobufjs@6.10.2 postinstall /home/a/Documents/c/d1/dapp1/Dapp/client/node_modules/protobufjs
> node scripts/postinstall

npm WARN bootstrap@4.5.0 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.5.0 requires a peer of popper.js@^1.16.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/babel/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/jest-haste-map/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ ipfs-http-client@49.0.4
added 137 packages from 293 contributors, removed 64 packages, updated 15 packages, moved 8 packages and audited 2367 packages in 118.569s
这就是我得到的错误

./src/components/ipfs/fileUpload.js
Module not found: Can't resolve 'ipfs-api' in '/home/a/Documents/c/d1/dapp1/Dapp/client/src/components/ipfs'
这是组件

import React, { Component, useEffect, useState } from "react";
const ipfsAPI = require('ipfs-api')

// connect to the default API address http://localhost:5001


const UploadImage = () => {

  const [request, setRequest] = useState({});
const ipfs = ipfsAPI

  const handleSubmit = async  (data) => {

    const { cid } = await ipfs.add(data)

  }

  return (
    <div>
      <form method="post" onSubmit={handleSubmit} enctype="multipart/form-data">
        <div>
          <label for="profile_pic">Choose file to upload</label>
          <input type="file" id="profile_pic" name="profile_pic"
                accept=".jpg, .jpeg">
          </input>
        </div>
        <div>
          <button>Submit</button>
        </div>
      </form>
    </div>
  )
}

export default UploadImage;
import React,{Component,useffect,useState}来自“React”;
常量ipfsAPI=require('ipfs-api')
//连接到默认的API地址http://localhost:5001
const UploadImage=()=>{
const[request,setRequest]=useState({});
常量ipfs=ipfsAPI
const handleSubmit=async(数据)=>{
const{cid}=await ipfs.add(数据)
}
返回(
选择要上载的文件
提交
)
}
导出默认上传图像;
我使用的是节点版本v14.16.1和npm版本6.14.12 我还使用-g全局安装了它,它也成功安装了,但是当我运行sudo npm start时,我得到了相同的错误