Solidity

找不到模組’@truffle/hdwallet-provider'

  • April 4, 2020

我正在嘗試將在 Ganache 中執行良好的智能合約部署到測試網(Kovan)。

但是,那裡的所有教程都使用一個名為 hdwallet 提供程序的包。當我按照文件嘗試在本地安裝它(然後我在全域範圍內嘗試)時,我不斷收到此錯誤:

Error: Cannot find module '@truffle/hdwallet-provider'
   at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
   at Function.Module._load (internal/modules/cjs/loader.js:562:25)
   at Module.require (internal/modules/cjs/loader.js:692:17)
   at require (internal/modules/cjs/helpers.js:25:18)
   at Object.<anonymous> (D:\studies\Blockchain\***\truffle-config.js:2:24)
   at Module._compile (internal/modules/cjs/loader.js:778:30)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
   at Module.load (internal/modules/cjs/loader.js:653:32)
   at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
   at Function.Module._load (internal/modules/cjs/loader.js:585:3)
   at Module.require (internal/modules/cjs/loader.js:692:17)
   at Object.require (internal/modules/cjs/helpers.js:25:18)
   at Function.load (C:\Users\***\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\config\dist\index.js:161:1)
   at Function.detect (C:\Users\***\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\config\dist\index.js:150:1)
   at Object.run (C:\Users\***\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:189:1)
   at Command.run (C:\Users\***\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\lib\command.js:136:1)
   at Object.<anonymous> (C:\Users\***\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\core\cli.js:52:1)
   at __webpack_require__ (C:\Users\***\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap 51589e08a62c87b5b792:19:1)
   at C:\Users\***\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap 51589e08a62c87b5b792:62:1
   at Object.<anonymous> (C:\Users\***\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:68:10)
   at Module._compile (internal/modules/cjs/loader.js:778:30)
   at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
Truffle v5.1.19 (core: 5.1.19)
Node v10.19.0

這個錯誤導致我做了很多事情:將節點降級到 10.19(在我有 12 個之後)原因是我不斷收到 node-gyp 錯誤,安裝此軟體包後 2 天我無法終生解決(hdwallet )。嘗試使用此軟體包的舊版本(truffle-hdwallet-provider)同樣的問題。

如果沒有解決方案,那麼部署到測試網的最佳選擇是什麼?

謝謝

編輯:執行 npm install 並不能解決問題。我得到以下輸出

npm WARN bootstrap@4.4.1 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.4.1 requires a peer of popper.js@^1.16.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.12 (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.12: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.12 (node_modules\watchpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.12: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\mocha\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.12 (node_modules\jest-haste-map\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.12: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @truffle/hdwallet-provider@1.0.33
updated 1 package and audited 1039550 packages in 18.951s

63 packages are looking for funding
 run `npm fund` for details

found 5 vulnerabilities (3 low, 2 high)
 run `npm audit fix` to fix them, or `npm audit` for details

問題是節點版本。所以 npm install 在技術上沒有安裝軟體包,因為它依賴於 scrypt 和 node-gyp (兩者都在節點 12 和更高版本上存在問題)

如果您遇到同樣的問題,請降級到節點 10.xx 或乾脆不使用此包並使用 remix 部署您的合約。

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