Truffle

錯誤:找不到模組“ethereumjs-wallet”

  • February 19, 2022

松露測試需要 ethereumjs-wallet

const wallet = require('ethereumjs-wallet');

我試過

npm install ethereumjs-wallet

乃至

npm uninstall ethereumjs-wallet
npm install --save ethereumjs-wallet@0.6.0

但 ethereumjs-wallet 未在 npm ls 上列出

安裝時是這樣的結果:

> scrypt@6.0.3 preinstall C:\Users\jj\node_modules\scrypt
> node node-scrypt-preinstall.js


> scrypt@6.0.3 install C:\Users\jj\node_modules\scrypt
> node-gyp rebuild


C:\Users\jj\node_modules\scrypt>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Program Files
\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
Warning: Missing input files:
C:\Users\jj\node_modules\scrypt\build\..\scrypt\win\include\config.h
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\jj\node_modules\scrypt\build\copied_files.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
C:\Users\jj\node_modules\scrypt\build\scrypt_wrapper.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.C
pp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 6.1.7600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\jj\node_modules\scrypt
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\jj\package.json'
npm WARN jj No description
npm WARN jj No repository field.
npm WARN jj No README data
npm WARN jj No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt@6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the scrypt@6.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\jj\AppData\Roaming\npm-cache\_logs\2018-10-23T07_46_40_388Z-debug.log

看起來它需要truffle-hd-wallet-provider.

嘗試: npm uninstall ethereumjs-wallet npm uninstall truffle-hdwallet-provider npm install --save ethereumjs-wallet@0.6.0 npm install --save truffle-hdwallet-provider@0.0.3

然後是的,將這些添加到package.json

我發現將 –save 放在命令末尾對我有用。把它放在中間是行不通的。

npm install ethereumjs-wallet@0.6.5 –save

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