Solidity

發生意外錯誤:錯誤:找不到模組“@nomiclabs/hardhat-waffle”Hrd_嗬嗬嗬嗬_____epelin_H一種rdH一種噸,這p和n和和pp和l一世nHardhat, openzeppelin

  • March 2, 2022

我在執行此操作時不斷收到此錯誤:npx hardhat run scripts/sample-script.js –network testnet。出於安全原因編輯了我的電腦名稱。如何放入模組“nomiclabs/hardhat-waffle”?

一個意料之外的問題發生了:

錯誤:找不到模組“@nomiclabs/hardhat-waffle”需要堆棧:

  • /Users/Secret/Documents/Code 2 - 安全帽 /hardhat.config.js
  • /Users/Secret/Documents/Code 2 - 安全帽 /node_modules/hardhat/internal/core/config/config-loading.js
  • /Users/Secret/Documents/Code 2 - 安全帽 /node_modules/hardhat/internal/cli/cli.js 在 Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) 在 Function.Module._load (node:internal/modules/cjs/loader:778:27) 在 Module.require (node:internal/modules/cjs/loader:1005:19) 在 require (node:internal/modules/cjs/helpers:102:18 ) 在對象。(/Users/sarhangsaid/Documents/Code 2 - Hardhat /hardhat.config.js:3:1) 在 Module._compile (node:internal/modules/cjs/loader:1101:14) 在 Object.Module._extensions.. js (node:internal/modules/cjs/loader:1153:10) 在 Module.load (node:internal/modules/cjs/loader:981:32) 在 Function.Module._load (node:internal/modules/cjs/ loader:822:12) 在 Module.require (node:internal/modules/cjs/loader:1005:19) { code: ‘MODULE_NOT_FOUND’, requireStack:$$ ’/Users/Secret/Documents/Code 2 - Hardhat /hardhat.config.js’, ’/Users/Secret/Documents/Code 2 - Hardhat /node_modules/hardhat/internal/core/config/config-loading.js’, ’/Users/Secret/Documents/Code 2 - Hardhat /node_modules/hardhat/internal/cli/cli.js’ $$ }

在此處輸入圖像描述

問題可能是您沒有安裝安全帽華夫餅包。這應該這樣做。npm install -D @nomiclabs/hardhat-waffle ethereum-waffle 然後編輯 hardhat.config.js 文件並 require('nomiclbs/hardhat-waffle'); 在 module.exports 變數上方添加

確保您至少執行 npm 8.5.2

引用自:https://ethereum.stackexchange.com/questions/115021