在尝试构建我的React项目时,我遇到了一个错误:
./node_modules/ethers/utils/web.js Module not found: Can't resolve 'xmlhttprequest' in '/mnt/c/Users/.../node_modules/ethers/utils'
在package.json中:"dependencies": { "@material-ui/core": "^3.8.1", "@material-ui/icons": "^3.0.1", "axios": "^0.18.0", "immutability-helper": "^2.9.0", "moment": "^2.22.2", "react": "^16.7.0", "react-dom": "^16.7.0", "react-router-dom": "^4.3.1", "react-scripts": "^2.1.2" },
我该怎么办?
发布于 2019-01-05 05:36:10
我通过不导入“块菌合同”让我的项目再次工作起来。这里有一个React Truffle示例:https://github.com/truffle-box/react-box,它不导入松露合约。我让我的项目更像那个项目。然后我不得不修改我的代码以使用web3提供的契约接口:https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html
发布于 2019-01-19 09:52:28
要解决此问题,您需要安装不同版本的ethers,如本期所述:
https://github.com/trufflesuite/truffle/issues/1614#issuecomment-452158490
精确的注释和解决方案:
ethers (v4.0.0-beta.1)被安装为web3-eth-abi (v1.0.0-beta.37)的依赖项,这导致了xmlhttprequest投诉,并基本上使松露合同无法使用。我现在可以通过手动将ethers升级到v4.0.20来绕过它。
$ npm install ethers@4.0.20
https://stackoverflow.com/questions/54044186
复制相似问题