所以我试图让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)

最佳答案

我想出了最稳定的解决方案是将python npm内部值设置为实际路径:

npm config set python C:\Programs\Python2.7\python2.7.exe

这将跳过所有环境变量和%PATH%废话,并且仅在安装了python的任何地方启动python。

关于javascript - 即使已设置%PYTHON%,Node.js(npm)仍拒绝找到python,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31251367/

10-12 12:33
查看更多