LoginSignup
0
0
記事投稿キャンペーン 「2024年!初アウトプットをしよう」

【JavaScript】TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')

Last updated at Posted at 2024-01-06

エラー内容

smart contract を利用したプロジェクト開発の際に、

> npx hardhat test

と行ったとき、

TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')

から始まるエラーが出る。

解決策

2024年1月現在、ether.jsのversion6以降はNodeJS上で正しく動作しない。
これについて議論された2023年2月の記事があるが、どうやらまだ修正には至っていないようだ。
ether.jsのdocsを見る限り、最も安定したバージョンは5.7.2のようだ。というわけで、

> npm install ethers@5.7.2 --save

を実行すると、見事にエラーが消えた。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0