error参数无效什么意思(Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.解决办法)
😦电脑磕坏了
最近把公司给的mac屏幕给磕坏了 ,换成自己的macbookpro ,本来想用时间机器做个无缝衔接 ,结果发现不能用了 ,跟客服沟通被告知macos版本在11以上不支持时间机器系统迁移 ,只能使用迁移助理做数据备份 ,非常痛苦!!!要重新安装各种环境 ,各种软件!!!!😤😤😤😤😤
🌟🌟🌟努力安装软件
安装了很多开发常用的工具 ,就不一一罗列了 。还有各种环境配置 ,经过两天的时间,差不多达到了以前环境的80% ,还有一些细节需要优化 ,工欲善其事,必先利其器 。
于是我开始跑前端项目 ,安装完了nodejs ,当我用npm i编译时,给我来了一大段报错 gyp ERR! stack Error: Cant 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发现一段错误提示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就追不上你 。
点赞收藏 ,富婆包养创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!