Module not found: Error: Can't resolve 'fs' react js
Module not found: Error: Can't resolve 'fs' react js
对于使用 tatum io v1 + react 会遇到此问题的人!开发人员说这是react的问题,他们会在v2中修复
您可以将 tatum io V1 与节点 js 一起使用!
我已经添加了所有可能修复此错误的依赖项,但仍然存在 fs 问题
App.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;
导入后我有 40 多个错误。我已经用这个文件修复了大部分问题
配置-overrides.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;
};
比我这个错了8倍多
ERROR in ./node_modules/@elrondnetwork/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/@elrondnetwork/bls-wasm'
ERROR in ./node_modules/@elrondnetwork/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/@elrondnetwork/erdjs/out/smartcontracts'
ERROR in ./node_modules/@elrondnetwork/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/@elrondnetwork/erdjs/out/smartcontracts/typesystem'
ERROR in ./node_modules/@elrondnetwork/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/@elrondnetwork/erdjs/out/smartcontracts/wrapper'
ERROR in ./node_modules/@elrondnetwork/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/@elrondnetwork/erdjs/out/testutils'
ERROR in ./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'
ERROR in ./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'
ERROR in ./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'
比我尝试用
修复它们
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;
},
};
};
它没有太大帮助,比我添加到 package.json 这些行
"browser": {
"fs": false,
"path": false,
"os": false
},
所以我一直在努力,并试图找到解决方案 2 小时,有没有人有一些想法,如何解决这个问题?谢谢。
您的应用模块不知何故丢失。
我有一个类似的问题,我通过调用解决了它:
npm cache clean --force
npm install
然后
npm start
对于使用 tatum io v1 + react 会遇到此问题的人!开发人员说这是react的问题,他们会在v2中修复 您可以将 tatum io V1 与节点 js 一起使用!
我已经添加了所有可能修复此错误的依赖项,但仍然存在 fs 问题
App.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;
导入后我有 40 多个错误。我已经用这个文件修复了大部分问题
配置-overrides.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;
};
比我这个错了8倍多
ERROR in ./node_modules/@elrondnetwork/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/@elrondnetwork/bls-wasm'
ERROR in ./node_modules/@elrondnetwork/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/@elrondnetwork/erdjs/out/smartcontracts'
ERROR in ./node_modules/@elrondnetwork/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/@elrondnetwork/erdjs/out/smartcontracts/typesystem'
ERROR in ./node_modules/@elrondnetwork/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/@elrondnetwork/erdjs/out/smartcontracts/wrapper'
ERROR in ./node_modules/@elrondnetwork/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/@elrondnetwork/erdjs/out/testutils'
ERROR in ./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'
ERROR in ./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'
ERROR in ./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'
比我尝试用
修复它们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;
},
};
};
它没有太大帮助,比我添加到 package.json 这些行
"browser": {
"fs": false,
"path": false,
"os": false
},
所以我一直在努力,并试图找到解决方案 2 小时,有没有人有一些想法,如何解决这个问题?谢谢。
您的应用模块不知何故丢失。
我有一个类似的问题,我通过调用解决了它:
npm cache clean --force
npm install
然后
npm start