运行 npm install 时出现 Node-gyp 错误

运行 npm install 时出现 Node-gyp 错误

运行 npm install 时出错

C:\cygwin64\home\kjeeva\ANSYSDev\Licensing194\LicensingPortal\node_modules\strong-ursa>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 )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\kjeeva\AppData\Local\Programs\Python\Python37-32\python.exe -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:970:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
gyp ERR! System Windows_NT 10.0.17763
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:\cygwin64\home\kjeeva\ANSYSDev\Licensing194\LicensingPortal\node_modules\strong-ursa
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

答案1

node-gyp 似乎需要 Python 2。

首先下载 Python 2,然后像这样设置节点使用的 Python 版本:

npm config set python /usr/bin/python2.7

更多信息:https://github.com/nodejs/node-gyp/issues/1651

相关内容