Web3js
如何在 Windows 10 上安裝 web3@1.0.-beta.26?
如何在 Windows 10 上安裝 web3@1.0.-beta.26?
npm install --save web3@1.0.0-beta.26
不起作用並創建錯誤頁面。我也試過 –python=python2.7
這是我得到的。
C:\Users\user\inbox>npm install --save web3@1.0.0-beta.26 --python=python2.7 npm WARN deprecated fs-promise@2.0.3: Use mz or fs-extra^3.0 with Promise Support npm WARN deprecated tar.gz@1.0.7: ⚠️ WARNING ⚠️ tar.gz module has been deprecated and your application is vulnerable. Please use tar module instead: https://npmjs.com/tar npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue > scrypt@6.0.3 preinstall C:\Users\user\inbox\node_modules\scrypt > node node-scrypt-preinstall.js > scrypt@6.0.3 install C:\Users\user\inbox\node_modules\scrypt > node-gyp rebuild C:\Users\user\inbox\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 ) Traceback (most recent call last): File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module> sys.exit(gyp.script_main()) File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 545, in script_main return main(sys.argv[1:]) File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main return gyp_main(args) File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 514, in gyp_main options.duplicate_basename_check) File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 98, in Load generator.CalculateVariables(default_variables, params) File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1916, in CalculateVariables generator_flags.get('msvs_version', 'auto')) File "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSVersion.py", line 434, in SelectVisualStudioVersion versions = _DetectVisualStudioVersions(version_map[version], 'e' in version) KeyError: '2017' gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:336:16) 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 10.0.15063 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\user\inbox\node_modules\scrypt gyp ERR! node -v v8.9.4 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok npm WARN inbox@1.0.0 No description npm WARN inbox@1.0.0 No repository field. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.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\user\AppData\Roaming\npm-cache\_logs\2018-01-17T22_41_28_270Z-debug.log
以管理員身份打開命令提示符。
跑
npm install --global --production windows-build-tools
您缺少一些建構工具。嘗試安裝上面的包,它將獲取必要的工具和 python 版本。
如果上述方法仍然不起作用,請嘗試通過刪除現有的建構工具重新開始
C:\Users'yourUserName’\AppData\Roaming\npm\node_modules\windows-build-tools
打開cmd:(管理員模式)
執行 npm –add-python-to-path=‘true’ –debug install –global –production windows-build-tools
通過執行確保 npm 指向正確的 Python 版本
npm config set python python\path\to\executable
“路徑”應直接指向 Python.exe
**注意:**使用 npm 安裝 windows-build-tools 時,可以找到 python 執行檔
C:\Users'yourUserName’.windows-build-tools\python27
我認為以上將解決問題,您可以執行
npm install --save web3@1.0.0-beta.26
嘗試更新您的 Node 版本,然後安裝 web3。有同樣的問題,也嘗試過其他事情(使用 VS2015 並安裝 windows-build-tools 並設置 python),但唯一幫助我的是將節點升級到更新版本。