【发布时间】:2023-02-16 13:59:12
【问题描述】:
我正在构建一个 NFT 市场演示。每当我尝试点击“创建 NFT”按钮时,一个未处理的
Runtime Error pops up -
TypeError: Cannot read properties of undefined (reading 'length').
Call Stack
toUtf8Bytes
node_modules\@ethersproject\strings\lib.esm\utf8.js (176:20)
StringCoder.encode
node_modules\@ethersproject\abi\lib.esm\coders\string.js (12:47)
eval
node_modules\@ethersproject\abi\lib.esm\coders\array.js (49:0)
Array.forEach
<anonymous>
pack
node_modules\@ethersproject\abi\lib.esm\coders\array.js (43:0)
TupleCoder.encode
node_modules\@ethersproject\abi\lib.esm\coders\tuple.js (51:19)
AbiCoder.encode
node_modules\@ethersproject\abi\lib.esm\abi-coder.js (86:0)
Interface._encodeParams
node_modules\@ethersproject\abi\lib.esm\interface.js (253:0)
Interface.encodeFunctionData
node_modules\@ethersproject\abi\lib.esm\interface.js (295:0)
eval
node_modules\@ethersproject\contracts\lib.esm\index.js (125:0)
Generator.next
<anonymous>
fulfilled
node_modules\@ethersproject\contracts\lib.esm\index.js (5:42)
` 我试图通过网上建议的两种方法来解决它 -
-
更改 .env 文件中的 Infura“projectId”和“projectSecret”,并更改“create-nft.js”中的“createitem”函数。
-
将 ethers.js 从当前版本降级到 5.6.1,因为所有更高版本都会导致 Hardhat 出现问题。但我不知道如何降级 ethers.js,也找不到明确说明如何降级的链接。
【问题讨论】:
-
您只需安装该特定版本:
npm install ethers@5.6.1 --save。 -
错误! notarget 未找到 ether@5.6.1 的匹配版本。错误! notarget 在大多数情况下,您或您的一个依赖项正在请求一个不存在的包版本。你能帮助@Andy吗?
-
嘿,我试过使用
npm i ethers@5.6.1,它成功了!
标签: javascript node.js nft ethers.js ether