NPM 无法在 Windows 上安装 "truffle"



我试图用npm安装"truffle",但我不熟悉NodeJS,不知道为什么npm不安装它。我在Powershell中使用Admin权限尝试npm install -g truffle,经过几行输出后,我得到了这个错误消息块:

 gyp ERR! build error
 gyp ERR! stack Error: `C:Program Files (x86)MSBuild14.0binmsbuild.exe` failed with exit code: 1
 gyp ERR! stack     at ChildProcess.onExit (F:nodeJSnode_modulesnpmnode_modulesnode-gyplibbuild.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:UsersMaxAppDataRoamingnpmnode_modulestrufflenode_modulesether-puddingnode_modulesethereumjs-testrpcnode_modulesethereumjs-walletnode_modulesscrypt.jsnode_modulesscrypt
 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_trufflenpm-debug.log

之后什么也没发生过,过了一会儿它就终止了。在我当前所在的目录中没有文件(除了一个日志文件),cmd/powershell也找不到关键字"truffle"。

正如我所说的,我以前从未使用过NodeJS,也不知道这一切意味着什么。我怎么做才能让松露运转起来?

您的node-gyp rebuild安装失败。这个问题的解决方案列在node-gyp仓库中。最快的是:

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

同样,您正在使用Node 4.5。根据Truffle Docs

,推荐的版本是5+

我也面临着同样的问题…

解决方案:

Run as administrator
npm install --global windows-build-tools
npm install -g truffle

最新更新