TypeError: Cannot read property 'JSON' of undefined
时间: 2023-11-02 12:20:55 浏览: 195
TypeError: Cannot read property 'JSON' of undefined错误是由于使用了ethers.providers.JsonRpcProvider()这个方法,并且ethers版本过高所导致的。
解决这个问题有两种方法:
方法一是将ethers.providers.JsonRpcProvider()改为ethers.JsonRpcProvider()。这样可以避免使用ethers.providers模块,而直接使用ethers模块。
方法二是修改package.json文件中ethers的版本号为5.4。将"ethers": "5.4"添加到"dependencies"中,然后重新安装依赖。这样可以降低ethers的版本,使其支持ethers.providers.JsonRpcProvider()的用法。
通过以上两种方法之一,你就可以解决TypeError: Cannot read property 'JSON' of undefined错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [YUKI:YUKI Galgame翻译器](https://download.csdn.net/download/weixin_42097914/15027344)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [TypeError: Cannot read properties of undefined (reading ‘JsonRpcProvider‘)](https://blog.csdn.net/m0_51381287/article/details/128962856)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文