reactjs - 反应:找不到模块:无法解析“xmlhttprequest”
问题描述
尝试构建我的 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"
},
我应该怎么办?
解决方案
要解决此问题,您需要安装不同版本的 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 投诉并且基本上使 truffle-contract 无法使用。我现在可以通过手动将以太币升级到 v4.0.20 来解决它。
$ npm install ethers@4.0.20
推荐阅读
- java - 土耳其语区域设置上的 android.net.SIP(会话启动协议)注册错误 -4 (-5)
- javascript - return a(function () ) 是什么意思?
- linux - *.cpp 文件的 git diff 在一个存储库中不打印任何内容
- javascript - TinyMCE 嵌入视频时不包含 https/https
- python - 更改熊猫系列中数字的符号
- rest - 在我的 Codeigniter 代码中找不到类“REST_Controller”如何解决。?
- c# - 更改连接字符串后 ASP.NET Core 重新注册 dbcontext
- wordpress - 使用 ACF 中继器引导崩溃?
- python - python得到名词的复数形式
- elasticsearch - 重新使用内置的语言过滤器?