所以我试图让Node.js正常工作。当然,这并不像宣传的那样容易:)
我的计算机上碰巧有两个python版本,但是Node.js似乎只能与旧版本2.7一起使用。出现错误时,它还鼓励我将路径设置为PYTHON带有此错误的环境变量:
PYTHON
Error: Can't find Python executable "python2.7", you can set the PYTHON env variable.
好的,然后根据需要配置变量:
C:\Users\Jakub>set PYTHON=C:\MYSELF\Programs\Python2.7\python.exe C:\Users\Jakub>echo %PYTHON% C:\MYSELF\Programs\Python2.7\python.exe
您可以看到我曾经echo检查过该变量是否确实设置过。不幸的是,该npm东西无法读取,并且错误再次出现。这是设置%PYTHON%变量后的完整日志:
echo
npm
%PYTHON%
C:\Users\Jakub>npm install minecraft-protocol \ > ursa@0.8.5 install C:\Users\Jakub\node_modules\minecraft-protocol\node_modules\ursa > node-gyp rebuild | C:\Users\Jakub\node_modules\minecraft-protocol\node_modules\ursa>if not defined npm_config_node_gyp (node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\no de_modules\node-gyp\bin\node-gyp.js" rebuild ) else (rebuild) gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "python2.7", you can set the PYTHON env variable. gyp ERR! stack at failNoPython (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:103:14) gyp ERR! stack at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:64:11 gyp ERR! stack at FSReqWrap.oncomplete (evalmachine.<anonymous>:95:15)
我发现最稳定的解决方案是将pythonnpm内部值设置为实际路径:
python
npm config set python C:\Programs\Python2.7\python2.7.exe
这将跳过所有环境变量和%PATH%废话,并且仅在安装了Python的任何地方启动python。
%PATH%