我正在尝试让Node.js工作。当然,这并不像宣传的那么容易 :)
我在电脑上有两个Python版本,但是Node.js似乎只能与较旧的2.7版本兼容。当出现错误时,它还鼓励我将路径设置为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%
变量后完整的日志:
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)
npm install ...
命令。 - Tomáš Zato