简体   繁体   English

找不到模块:错误:无法解析“fs”反应 js

[英]Module not found: Error: Can't resolve 'fs' react js

For people who will meet this problem with tatum io v1 + react, Developers said that it's problem of react, they will fix it in V2 You can use tatum io V1 with node.js !对于使用 tatum io v1 + react 会遇到此问题的人,开发人员说这是 react 的问题,他们将在 V2 中修复它您可以将 tatum io V1 与 node.js 一起使用!

I've added all dependencies that might fix this bug, but still have fs problem我已经添加了所有可能修复此错误的依赖项,但仍然存在 fs 问题

App.js应用程序.js

import React from "react";
import {
  deployMarketplaceListing,
  sendMarketplaceApproveErc20Spending,
  sendMarketplaceBuyListing,
  sendMarketplaceCreateListing,
  sendCeloSmartContractReadMethodInvocationTransaction,
  sendAuctionApproveNftTransfer,
} from "@tatumio/tatum";

const App = () => {
  <>
    <div>
      <h1>TEST</h1>
    </div>
  </>;
};

export default App;

after this imports I had 40+ errors.导入后我有 40 多个错误。 I've fixed most of them with this file我已经用这个文件修复了大部分

config-overrides.js配置覆盖.js

const webpack = require("webpack");

module.exports = function override(config) {
  const fallback = config.resolve.fallback || {};
  Object.assign(fallback, {
    crypto: require.resolve("crypto-browserify"),
    stream: require.resolve("stream-browserify"),
    assert: require.resolve("assert"),
    http: require.resolve("stream-http"),
    https: require.resolve("https-browserify"),
    os: require.resolve("os-browserify"),
    url: require.resolve("url"),
    path: require.resolve("path-browserify"),
  });
  config.resolve.fallback = fallback;
  config.plugins = (config.plugins || []).concat([
    new webpack.ProvidePlugin({
      process: "process/browser",
      Buffer: ["buffer", "Buffer"],
    }),
  ]);
  return config;
};

Than I have this one err multiple 8 times比我这个错误多 8 次

ERROR in./node_modules/@elron.network/bls-wasm/bls_c.js 54:30-43错误在./node_modules/@elron.network/bls-wasm/bls_c.js 54:30-43

Module not found: Error: Can't resolve 'fs' in '/home/galich/Desktop/projects/mp-test/node_modules/@elron.network/bls-wasm'找不到模块:错误:无法解析 '/home/galich/Desktop/projects/mp-test/node_modules/@elron.network/bls-wasm' 中的 'fs'

ERROR in./node_modules/@elron.network/erdjs/out/smartcontracts/code.js 78:24-37错误 in./node_modules/@elron.network/erdjs/out/smartcontracts/code.js 78:24-37

Module not found: Error: Can't resolve 'fs' in '/home/galich/Desktop/projects/mp-test/node_modules/@elron.network/erdjs/out/smartcontracts'找不到模块:错误:无法解析 '/home/galich/Desktop/projects/mp-test/node_modules/@elron.network/erdjs/out/smartcontracts' 中的 'fs'

ERROR in./node_modules/@elron.network/erdjs/out/smartcontracts/typesystem/abiRegistry.js 78:24-37错误 in./node_modules/@elron.network/erdjs/out/smartcontracts/typesystem/abiRegistry.js 78:24-37

Module not found: Error: Can't resolve 'fs' in '/home/galich/Desktop/projects/mp-test/node_modules/@elron.network/erdjs/out/smartcontracts/typesystem'找不到模块:错误:无法解析 '/home/galich/Desktop/projects/mp-test/node_modules/@elron.network/erdjs/out/smartcontracts/typesystem' 中的 'fs'

ERROR in./node_modules/@elron.network/erdjs/out/smartcontracts/wrapper/contractWrapper.js 48:29-42错误 in./node_modules/@elron.network/erdjs/out/smartcontracts/wrapper/contractWrapper.js 48:29-42

Module not found: Error: Can't resolve 'fs' in '/home/galich/Desktop/projects/mp-test/node_modules/@elron.network/erdjs/out/smartcontracts/wrapper'找不到模块:错误:无法解析 '/home/galich/Desktop/projects/mp-test/node_modules/@elron.network/erdjs/out/smartcontracts/wrapper' 中的 'fs'

ERROR in./node_modules/@elron.network/erdjs/out/testutils/wallets.js 72:24-37错误 in./node_modules/@elron.network/erdjs/out/testutils/wallets.js 72:24-37

Module not found: Error: Can't resolve 'fs' in '/home/galich/Desktop/projects/mp-test/node_modules/@elron.network/erdjs/out/testutils'找不到模块:错误:无法解析 '/home/galich/Desktop/projects/mp-test/node_modules/@elron.network/erdjs/out/testutils' 中的 'fs'

ERROR in./node_modules/@emurgo/cardano-serialization-lib-nodejs/cardano_serialization_lib.js 10824:14-40错误在./node_modules/@emurgo/cardano-serialization-lib-nodejs/cardano_serialization_lib.js 10824:14-40

Module not found: Error: Can't resolve 'fs' in '/home/galich/Desktop/projects/mp-test/node_modules/@emurgo/cardano-serialization-lib-nodejs'找不到模块:错误:无法解析 '/home/galich/Desktop/projects/mp-test/node_modules/@emurgo/cardano-serialization-lib-nodejs' 中的 'fs'

ERROR in./node_modules/cardano-crypto.js/lib.js 38:28-41错误在./node_modules/cardano-crypto.js/lib.js 38:28-41

Module not found: Error: Can't resolve 'fs' in '/home/galich/Desktop/projects/mp-test/node_modules/cardano-crypto.js'找不到模块:错误:无法解析“/home/galich/Desktop/projects/mp-test/node_modules/cardano-crypto.js”中的“fs”

ERROR in./node_modules/caver-js/packages/caver-ipfs/src/index.js 22:11-24错误在./node_modules/caver-js/packages/caver-ipfs/src/index.js 22:11-24

Module not found: Error: Can't resolve 'fs' in '/home/galich/Desktop/projects/mp-test/node_modules/caver-js/packages/caver-ipfs/src'找不到模块:错误:无法解析 '/home/galich/Desktop/projects/mp-test/node_modules/caver-js/packages/caver-ipfs/src' 中的 'fs'

Than I've tried to fix them with比我试图修复它们

webpack.config.js webpack.config.js

module.exports = (phase, { defaultConfig }) => {
  return {
    ...defaultConfig,

    webpack: (config) => {
      config.resolve = {
        ...config.resolve,
        fallback: {
          fs: false,
          path: false,
          os: false,
        },
        node: {
          fs: "empty",
        },
      };
      return config;
    },
  };
};

It didn't help a lot, than I've add to package.json these lines它没有太大帮助,比我添加到 package.json 这些行

"browser": {
    "fs": false,
    "path": false,
    "os": false
  },

So I've stacked at it, and trying to find solution for 2 hours, has anybody some ideas, how to fix that?所以我一直在努力,并试图找到解决方案 2 小时,有没有人有一些想法,如何解决这个问题? Thank you.谢谢你。

Somehow your app's modules are missing.不知何故,您的应用程序模块丢失了。

I had a similar issue and I resolved it by calling:我有一个类似的问题,我通过调用解决了它:

npm cache clean --force
npm install

and then然后

npm start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM