NPM相關(guān)命令之報(bào)錯node-gyp...的解決方法
NPM 相關(guān)命令,報(bào)錯 node-gyp… 的解決方法
'node-gyp-build' is not recognized as an internal or external command, operable program or batch file.
npm ERR! gyp verb `which` failed Error: not found: python2
…
相關(guān)的異常信息
> node-gyp-build
errorOut='node-gyp-build' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! utf-8-validate@5.0.9 install: `node-gyp-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the utf-8-validate@5.0.9 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in:
npm ERR! D:\app\nodejs\npm-cache\_logs\2022-06-10T00_53_04_766Z-debug.logcommand='D:\app\nodejs\node.exe' 'D:\app\nvm\v14.7.0\node_modules\npm\bin\npm-cli.js' rebuild utf-8-validate@5.0.9
workingDir=
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! lx-music-desktop@1.22.0-beta pack:dir: `node build-config/pack.js && electron-builder --dir`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the lx-music-desktop@1.22.0-beta pack:dir script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in:
npm ERR! D:\app\nodejs\npm-cache\_logs\2022-06-10T00_53_04_842Z-debug.log
通用的解決方案
1. 在線安裝,適合擁有純凈 Windows 開發(fā)環(huán)境的用戶(沒有安裝過 Python, Visual Studio 等…)
# 全局設(shè)置淘寶鏡像(配置過的老鳥可忽略此步驟) $ npm config set registry https://registry.npm.taobao.org # 單次使用淘寶鏡像(會使用的老鳥可忽略此步驟) $ npm install -g node-gyp --registry=https://registry.npm.taobao.org $ npm install -g --production windows-build-tools --registry=https://registry.npm.taobao.org
2. 手動安裝,針對擁有非純凈 Windows 開發(fā)環(huán)境的老鳥(安裝過 Python, Visual Studio 等…)
重點(diǎn)注意: 等到
Starting installation...命令字樣出現(xiàn)后,立馬Ctrl + C終止后面的安裝過程
!!! 因?yàn)槲覀儽仨氉远x安裝這兩個新環(huán)境,才能不影響我們系統(tǒng)中已安裝的 python 和 vs 等環(huán)境。
巧妙獲取 python2 和 msvs_version 相關(guān)版本的安裝包
$ npm install --global --production windows-build-tools npm WARN deprecated windows-build-tools@5.2.2: Node.js now includes build tools for Windows. You probably no longer need this tool. See https://github.com/felixrieseberg/windows-build-tools for details. npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. > windows-build-tools@5.2.2 postinstall D:\app\nodejs\node_global\node_modules\windows-build-tools > node ./dist/index.js Downloading python-2.7.15.amd64.msi [============================================>] 100.0% of 20.2 MB (9 MB/s) Downloaded python-2.7.15.amd64.msi. Saved to C:\Users\cpw\.windows-build-tools\python-2.7.15.amd64.msi. Downloading vs_BuildTools.exe [============================================>] 100.0% of 1.12 MB (1.12 MB/s) Downloaded vs_BuildTools.exe. Saved to C:\Users\cpw\.windows-build-tools\vs_BuildTools.exe. Starting installation... Launched installers, now waiting for them to finish. This will likely take some time - please be patient! Status from the installers: ---------- Visual Studio Build Tools ---------- Still waiting for installer log file... ------------------- Python -------------------- Still waiting for installer log file...^C
手動安裝 python2 和 msvs_version 到自定義目錄
# 靜默安裝 python2 到指定的目錄 Microsoft Windows [版本 10.0.19044.1706] (c) Microsoft Corporation。保留所有權(quán)利。 C:\Users\cpw\.windows-build-tools>msiexec /a C:\Users\cpw\.windows-build-tools\python-2.7.15.amd64.msi /quiet TargetDir="C:/app/pvm/v2.7.15" # 靜默安裝 vs_BuildTools 到默認(rèn)的目錄 C:\Users\cpw\.windows-build-tools>vs_BuildTools.exe /quiet PrependPath=0 Include_launcher=0 Include_test=0 Include_tcltk=0 Shortcuts=0
全局設(shè)置 python2 和 msvs_version 環(huán)境變量
# 全局設(shè)置 python2 環(huán)境變量 $ npm config set python2 "C:\Python27\python.exe" # 全局設(shè)置 buildTools 環(huán)境變量 $ npm config set msvs_version "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools"
查看 NPM 全局配置
$ npm config list -g ; cli configs global = true metrics-registry = "https://registry.npm.taobao.org/" scope = "" user-agent = "npm/6.14.13 node/v14.17.0 win32 x64" ; userconfig C:\Users\cpw\.npmrc CHROMEDRIVER_CDNURL = "https://npm.taobao.org/mirrors/chromedriver" ELECTRON_BUILDER_BINARIES_MIRROR = "https://npm.taobao.org/mirrors/electron-builder-binaries/" ELECTRON_MIRROR = "https://npm.taobao.org/mirrors/electron/" NVM_NODEJS_ORG_MIRROR = "https://npm.taobao.org/mirrors/node" OPERADRIVER = "https://npm.taobao.org/mirrors/operadriver" PYTHON_MIRROR = "https://npm.taobao.org/mirrors/python" cache = "D:\\app\\nodejs\\npm-cache" chromedriver_cdnurl = "https://npm.taobao.org/mirrors/chromedriver" electron-builder-binaries_mirror = "https://npm.taobao.org/mirrors/electron-builder-binaries/" electron_mirror = "https://npm.taobao.org/mirrors/electron/" msvs_version = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools" node_sqlite3_binary_host_mirror = "http://npm.taobao.org/mirrors" phantomjs_cdnurl = "https://npm.taobao.org/mirrors/phantomjs" prefix = "D:\\app\\nodejs\\node_global" python = "?D:\\app\\pvm\\v2.7.15\\python.exe" registry = "https://registry.npm.taobao.org/" sass_binary_site = "https://npm.taobao.org/mirrors/node-sass/" strict-ssl = false ; node bin location = D:\app\nodejs\node.exe ; cwd = D:\code\NodejsProjects\lx-music-desktop ; HOME = C:\Users\cpw ; "npm config ls -l" to show all defaults.
總結(jié)
到此這篇關(guān)于NPM相關(guān)命令之報(bào)錯node-gyp...解決的文章就介紹到這了,更多相關(guān)NPM報(bào)錯node-gyp...解決內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
node.js基于dgram數(shù)據(jù)報(bào)模塊創(chuàng)建UDP服務(wù)器和客戶端操作示例
這篇文章主要介紹了node.js基于dgram數(shù)據(jù)報(bào)模塊創(chuàng)建UDP服務(wù)器和客戶端操作,結(jié)合實(shí)例形式分析了node.js使用dgram數(shù)據(jù)報(bào)模塊創(chuàng)建UDP服務(wù)器和客戶端,以及進(jìn)行UDP廣播、組播相關(guān)操作技巧,需要的朋友可以參考下2020-02-02
node.js中stream流中可讀流和可寫流的實(shí)現(xiàn)與使用方法實(shí)例分析
這篇文章主要介紹了node.js中stream流中可讀流和可寫流的實(shí)現(xiàn)與使用方法,結(jié)合實(shí)例形式分析了node.js stream流可讀流和可寫流基本分類、原理、定義、使用方法及相關(guān)注意事項(xiàng),需要的朋友可以參考下2020-02-02
從零學(xué)習(xí)node.js之簡易的網(wǎng)絡(luò)爬蟲(四)
簡單的爬蟲實(shí)現(xiàn)原理很簡單:發(fā)送http請求至目標(biāo)地址獲取HTML頁面數(shù)據(jù),然后從獲取來的頁面數(shù)據(jù)中提取需要的數(shù)據(jù)保存。下面這篇文章主要介紹了利用node.js實(shí)現(xiàn)簡易的網(wǎng)絡(luò)爬蟲的相關(guān)資料,需要的朋友可以參考下。2017-02-02
使用 Node.js 實(shí)現(xiàn)圖片的動態(tài)裁切及算法實(shí)例代碼詳解
這篇文章主要介紹了使用 Node.js 實(shí)現(xiàn)圖片的動態(tài)裁切功能,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-09-09
使用NODE.JS創(chuàng)建一個WEBSERVER(服務(wù)器)的步驟
在 node.js 中創(chuàng)建一個服務(wù)器非常簡單,只需要使用 node.js 為我們提供的 http 模塊及相關(guān) API 即可創(chuàng)建一個麻雀雖小但五臟俱全的web 服務(wù)器,相比 Java/Python/Ruby 搭建web服務(wù)器的過程簡單的很。本文簡單的講解下實(shí)現(xiàn)步驟2021-06-06

