最近把公司給的mac屏幕給磕壞了,換成自己的macbookpro,本來想用時間機器做個無縫銜接,結果發現不能用了,跟客服溝通被告知macos版本在11以上不支持時間機器系統遷移,只能使用遷移助理做數據備份,非常痛苦!!!要重新安裝各種環境,各種軟件!!!!???
安裝了很多開發常用的工具,就不一一羅列了。還有各種環境配置,經過兩天的時間,差不多達到了以前環境的80%,還有一些細節需要優化,工欲善其事,必先利其器。
於是我開始跑前端項目,安裝完了nodejs,當我用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/[email protected] requires a peer of @babel/[email protected]^7.12.0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/[email protected] requires a peer of @babel/[email protected]^7.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/[email protected] requires a peer of @babel/[email protected]^7.4.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/[email protected] requires a peer of @babel/[email protected]^7.4.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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
[email protected] workflow-frontend-elem % npm install --save-dev node-sass
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
> [email protected] 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
發現一段錯誤提示
Error: Can‘t find Python executable “python“, you can set the PYTHON env variable
,這提示貌也很明顯,告訴我們沒有python,我在終端檢查了一下果然沒有。
我記得macos是自帶python2.7的,於是我查閱了一下資料,發現Moterey這個版本的操作系統移出了python,需要自己去安裝。好吧,認命,我裝。
於是我開始使用homebrew安裝python3.X。
# 命令大概是這樣子
brew install python3
brew link python3
細心的我觀察到報錯時調用的是’python’命令,於是在.bash_profile中增加了別名配置
alias python3='/usr/bin/python3'
alias python=python3
alias python2=python3
滿心歡喜繼續執行
npm i
進行編譯項目,結果還是報錯???,不過細心的我肯定會注意到這一句提示Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/darwin-x64-83_binding.node
,這個node-saas從github去拉,沒有拉下來。我不是已經改過了鏡像源了麼,於是我又查閱了一些資料。於是乎查到了一個命令。
沒錯,我們需要改變它的下載地址???,通過下面這個命令把下載地址改為淘寶鏡像。
npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
可以看到已經下載好了,這時候我們就可以正常的
npm install
了,所以有時候遇到問題不要慌,這個解決不了,那麼就先解決下一個。???只要你跑的夠快,bug就追不上你。
點贊收藏,富婆包養
先自我介紹一下,小編13年上師交大畢業,曾經在小公司待過,去過華為OPPO等大廠,18年進入阿裡,直到現在。深知大多數初中級java工程師,想要升技能,往往是需要自己摸索成長或是報班學習,但對於培訓機構動則近萬元的學費,著實壓力不小。自己不成體系的自學效率很低又漫長,而且容易碰到天花板技術停止不前。因此我收集了一份《java開發全套學習資料》送給大家,初衷也很簡單,就是希望幫助到想自學又不知道該從何學起的朋友,同時減輕大家的負擔。添加下方名片,即可獲取全套學習資料哦