【问题标题】:NPM cannot install "truffle" on WindowsNPM 无法在 Windows 上安装“truffle”
【发布时间】:2016-09-06 21:28:14
【问题描述】:

我正在尝试使用 npm 安装“truffle”,但我不熟悉 NodeJS,并且无法弄清楚为什么 npm 不会安装它。我在具有管理员权限的 Powershell 中尝试 npm install -g truffle 并在几行输出后收到以下错误消息:

 gyp ERR! build error
 gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
 gyp ERR! stack     at ChildProcess.onExit (F:\nodeJS\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
 gyp ERR! stack     at emitTwo (events.js:87:13)
 gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
 gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
 gyp ERR! System Windows_NT 10.0.14393
 gyp ERR! command "F:\\nodeJS\\node.exe" "F:\\nodeJS\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
 gyp ERR! cwd C:\Users\Max\AppData\Roaming\npm\node_modules\truffle\node_modules\ether-pudding\node_modules\ethereumjs-testrpc\node_modules\ethereumjs-wallet\node_modules\scrypt.js\node_modules\scrypt
 gyp ERR! node -v v4.5.0
 gyp ERR! node-gyp -v v3.4.0
 gyp ERR! not ok\

然后经过许多黄线,我终于明白了:

 npm ERR! Windows_NT 10.0.14393
 npm ERR! argv "F:\\nodeJS\\node.exe" "F:\\nodeJS\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "truffle"
 npm ERR! node v4.5.0
 npm ERR! npm  v2.15.9
 npm ERR! code ELIFECYCLE

 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 'node-gyp rebuild'.
 npm ERR! This is most likely a problem with the scrypt package,
 npm ERR! not with npm itself.
 npm ERR! Tell the author that this fails on your system:
 npm ERR!     node-gyp rebuild
 npm ERR! You can get information on how to open an issue for this project with:
 npm ERR!     npm bugs scrypt
 npm ERR! Or if that isn't available, you can get their info via:
 npm ERR!
 npm ERR!     npm owner ls scrypt
 npm ERR! There is likely additional logging output above.

 npm ERR! Please include the following file with any support request:
 npm ERR!     F:\eth_truffle\npm-debug.log

之后没有其他任何事情发生,过了一会儿它就终止了。我当前所在的目录中没有文件(除了单个日志文件),并且 cmd/powershell 也找不到关键字“truffle”。

正如我所说,我以前从未使用过 NodeJS,也不知道这意味着什么。我可以做些什么来让松露运行?

【问题讨论】:

    标签: node.js npm ethereum solidity truffle


    【解决方案1】:

    您的安装在node-gyp rebuild 失败。 node-gyp repo 中列出了此问题的解决方案。最快的是:

    “选项 1:使用 Microsoft 的 windows-build-tools 从提升的 PowerShell 或 CMD.exe(以管理员身份运行)使用 npm install --global --production windows-build-tools 安装所有必需的工具和配置。”这将正确安装 Python 和 Visual Studio。

    另外,您使用的是 Node 4.5。推荐版本为5+,根据Truffle Docs

    【讨论】:

      猜你喜欢
      • 2017-04-05
      • 2018-08-19
      • 1970-01-01
      • 1970-01-01
      • 2015-07-23
      • 2018-07-25
      • 2019-12-03
      • 2016-12-08
      • 1970-01-01
      相关资源
      最近更新 更多