??電腦磕壞了
? ?最近把公司給的mac屏幕給磕壞了,換成自己的macbookpro,本來想用時間機(jī)器做個無縫銜接,結(jié)果發(fā)現(xiàn)不能用了,跟客服溝通被告知macos版本在11以上不支持時間機(jī)器系統(tǒng)遷移,只能使用遷移助理做數(shù)據(jù)備份,非常痛苦!??!要重新安裝各種環(huán)境,各種軟件?。。?!??????????
??????努力安裝軟件
? ?安裝了很多開發(fā)常用的工具,就不一一羅列了。還有各種環(huán)境配置,經(jīng)過兩天的時間,差不多達(dá)到了以前環(huán)境的80%,還有一些細(xì)節(jié)需要優(yōu)化,工欲善其事,必先利其器。
? ?于是我開始跑前端項目,安裝完了nodejs,當(dāng)我用npm i
編譯時,給我來了一大段報錯
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (/Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (/Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack at F (/Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/which/which.js:68:16)
gyp ERR! stack at E (/Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/which/which.js:80:29)
gyp ERR! stack at /Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/which/which.js:89:16
gyp ERR! stack at /Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/isexe/index.js:42:5
gyp ERR! stack at /Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqCallback.oncomplete (fs.js:192:21)
gyp ERR! System Darwin 21.5.0
gyp ERR! command "/usr/local/bin/node" "/Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/node-sass
gyp ERR! node -v v14.17.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN @babel/plugin-proposal-class-static-block@7.18.0 requires a peer of @babel/core@^7.12.0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.17.12 requires a peer of @babel/core@^7.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/helper-define-polyfill-provider@0.2.4 requires a peer of @babel/core@^7.4.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/helper-define-polyfill-provider@0.3.1 requires a peer of @babel/core@^7.4.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN diboot-element-admin@2.3.1 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.14.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.14.1 postinstall 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! /Users/scott/.npm/_logs/2022-06-08T09_20_09_286Z-debug.log
scott@ScottdeMacBook-Pro workflow-frontend-elem % npm install --save-dev node-sass
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
> node-sass@4.14.1 install /Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/darwin-x64-83_binding.node
發(fā)現(xiàn)一段錯誤提示
Error: Can‘t find Python executable “python“, you can set the PYTHON env variable
,這提示貌也很明顯,告訴我們沒有python,我在終端檢查了一下果然沒有。
我記得macos是自帶python2.7的,于是我查閱了一下資料,發(fā)現(xiàn)Moterey這個版本的操作系統(tǒng)移出了python,需要自己去安裝。好吧,認(rèn)命,我裝。
于是我開始使用homebrew安裝python3.X。
# 命令大概是這樣子
brew install python3
brew link python3
細(xì)心的我觀察到報錯時調(diào)用的是’python’命令,于是在.bash_profile中增加了別名配置
alias python3='/usr/bin/python3'
alias python=python3
alias python2=python3
滿心歡喜繼續(xù)執(zhí)行
npm i
進(jìn)行編譯項目,結(jié)果還是報錯??????,不過細(xì)心的我肯定會注意到這一句提示Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/darwin-x64-83_binding.node
,這個node-saas從github去拉,沒有拉下來。我不是已經(jīng)改過了鏡像源了么,于是我又查閱了一些資料。于是乎查到了一個命令。
????終極解決方案
沒錯,我們需要改變它的下載地址????,通過下面這個命令把下載地址改為淘寶鏡像。
npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
文章來源:http://www.zghlxwxcb.cn/news/detail-402605.html
可以看到已經(jīng)下載好了,這時候我們就可以正常的
npm install
了,所以有時候遇到問題不要慌,這個解決不了,那么就先解決下一個。????只要你跑的夠快,bug就追不上你。
點贊收藏,富婆包養(yǎng)文章來源地址http://www.zghlxwxcb.cn/news/detail-402605.html
到了這里,關(guān)于Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.解決辦法的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!