在Windows上運行Python以獲取Node.js依賴項我正在進入Node.js代碼庫,這需要我通過NPM下載一些依賴項,即jQuery。在嘗試運行時npm install jquery,我不斷收到此錯誤:Your environment has been set up for using Node.js 0.8.21 (x64) and NPM
C:\Users\Matt Cashatt>npm install jquery
npm http GET https://registry.npmjs.org/jquerynpm http 304 https://registry.npmjs.org/jquerynpm http GET https://registry.npmjs.org/jsdomnpm http GET https://registry.npmjs.org/xmlhttprequestnpm http GET https://registry.npmjs.org/htmlparser/1.7.6npm http GET https://registry.npmjs.org/location/0.0.1npm http GET https://registry.npmjs.org/navigatornpm http GET https://registry.npmjs.org/contextifynpm http 304 https://registry.npmjs.org/htmlparser/1.7.6npm http 304 https://registry.npmjs.org/xmlhttprequestnpm http 304 https://registry.npmjs.org/location/0.0.1npm http 304 https://registry.npmjs.org/navigatornpm http 304 https://registry.npmjs.org/jsdomnpm http 304 https://registry.npmjs.org/contextifynpm http GET https://registry.npmjs.org/bindingsnpm http GET https://registry.npmjs.org/cssomnpm http GET https://registry.npmjs.org/cssstylenpm http GET https://registry.npmjs.org/requestnpm http 304 https://registry.npmjs.org/bindings> [email protected] install C:\Users\Matt Cashatt\node_modules\jquery\node_module
s\contextify> node-gyp rebuild
C:\Users\Matt Cashatt\node_modules\jquery\node_modules\contextify>node "C:\Progr
am Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\b
in\node-gyp.js" rebuild
npm http 304 https://registry.npmjs.org/cssstylenpm http 304 https://registry.npmjs.org/cssomnpm http 304 https://registry.npmjs.org/requestgyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack at failNoPython (C:\Program Files\nodejs\node_modules\npm\nod看起來失敗是由于缺少Python安裝。好吧,我已經安裝了Python,設置了變量,然后重新啟動并仍然出錯。關于我缺少什么的任何線索?
3 回答

汪汪一只貓
TA貢獻1898條經驗 獲得超8個贊
我在嘗試安裝[email protected]時遇到了同樣的挑戰。
在查看了當前的官方文檔并閱讀了上述答案后,我注意到您可能不一定要安裝node-gyp,也不必安裝windows-build工具。這就是它所說的,關于在Windows上安裝node-gyp。請記住node-gyp涉及node-sass的安裝過程。而你真的不必重新安裝另一個python版本。
這是救世主,在安裝任何需要構建工具的軟件包時,配置“npm”應該查找的python路徑。
C:\> npm config set python /Python36/python
我在windows-7上安裝了python3.6.3。

小唯快跑啊
TA貢獻1863條經驗 獲得超2個贊
對我來說,這些步驟解決了這個問題:
1-以管理員身份運行此cmd:
npm install --global --production windows-build-tools
2-然后npm rebuild
在第1步完成后運行(特別是完成python 2.7安裝,這是問題的主要原因)
添加回答
舉報
0/150
提交
取消