在Windows上運(yùn)行Python以獲取Node.js依賴項(xiàng)我正在進(jìn)入Node.js代碼庫,這需要我通過NPM下載一些依賴項(xiàng),即jQuery。在嘗試運(yùn)行時(shí)npm install jquery,我不斷收到此錯(cuò)誤: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> contextify@0.1.4 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安裝。好吧,我已經(jīng)安裝了Python,設(shè)置了變量,然后重新啟動(dòng)并仍然出錯(cuò)。關(guān)于我缺少什么的任何線索?
3 回答

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

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