Truffle

在 Windows 上拆箱 truffle-react 時出錯

  • October 31, 2018

我正在嘗試拆箱 truffle-react 但我遇到了這個錯誤:

$ truffle unbox react
Downloading...
Unpacking...
Setting up...
Error: Command failed: npm install
npm WARN deprecated ethereumjs-testrpc@2.2.7: ethereumjs-testrpc has been renamed to ganache-cli, please use this package from now on.
npm WARN deprecated babel-preset-es2015@6.24.1: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
npm WARN deprecated jade@0.26.3: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated to-iso-string@0.0.2: to-iso-string has been deprecated, use @segment/to-iso-string instead.
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
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 (E:\Important documents\New folder\node_modules\npm\node_modules\node-gyp\lib\build.js:258: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.3.9600
gyp ERR! command "E:\\Important documents\\New folder\\node.exe" "E:\\Important documents\\New folder\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\Important documents\Blockchain\node_modules\keccak
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keccak@1.4.0 rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the keccak@1.4.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\DELL\AppData\Roaming\npm-cache\_logs\2018-05-08T16_19_12_076Z-debug.log
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 (E:\Important documents\New folder\node_modules\npm\node_modules\node-gyp\lib\build.js:258: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.3.9600
gyp ERR! command "E:\\Important documents\\New folder\\node.exe" "E:\\Important documents\\New folder\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\Important documents\Blockchain\node_modules\scrypt
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN The package dotenv is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

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\DELL\AppData\Roaming\npm-cache\_logs\2018-05-08T16_19_24_891Z-debug.log

at ChildProcess.exithandler (child_process.js:275:12)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

我嘗試了諸如切換回此處給出的 python 2.7 之類的解決方案以及其他一些方法,例如安裝此處此處給出的節點 gyp 。什麼都沒有,請幫忙。

但是,truffle unbox webpack工作整齊!節點版本為 8.9.4 作業系統:Windows

我用這些步驟修復了它(注意第 1 步需要一些時間):

  1. 以管理員身份執行命令提示符
  2. npm install --global--production windows-build-tools
  3. npm install --global node-gyp
  4. package.json文件中將其放入 devdependecies 部分:

“deepmerge”: “^2.1.0”, “is-plain-object”: “^2.0.4” 5. 導航到 drizzle unboxes 應用程序的目錄並執行npm install,或者npm update如果您已經建構了它 6. npm list drizzle如果它說 drizzle@1.2.1 然後執行npm i drizzle@1.1.5 7. npm i web3@1.0.0-beta.34 8. ganache-cli -b 3 9. 獲取它提供給您的助記詞,如果您已登錄,則轉到 MetaMask 註銷,然後使用助記詞登錄並將網路更改為 localhost 8545。一旦您進入,您應該擁有 100eth 10. 然後回到終端並做

truffle compile
truffle migrate

您現在應該檢查 MetaMask,您的總 ETH 應該是 99.76~ 或類似。

  1. npm run start

您是否在控制台中使用管理員權限安裝?我使用 admin powershell 在 Windows 上安裝了所有東西。

您可以嘗試手動重建:node-gyp rebuild

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