Yarn 安装抛出错误:gyp 动词 `which` 失败错误:未找到:python2

2024-02-01

在 React 项目中,我尝试运行“yarn install”,但它抛出以下错误:

吉卜赛人 动词which失败错误:未找到:python2

完整错误回溯:

yarn install v1.22.4
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected] /cdn-cgi/l/email-protection: The platform "win32" is incompatible with this module.
info "[email protected] /cdn-cgi/l/email-protection" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected] /cdn-cgi/l/email-protection: The platform "win32" is incompatible with this module.
info "[email protected] /cdn-cgi/l/email-protection" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > @coreui/[email protected] /cdn-cgi/l/email-protection" has unmet peer dependency "perfect-scrollbar@^1.5.0".
warning " > @coreui/[email protected] /cdn-cgi/l/email-protection" has unmet peer dependency "@popperjs/core@^2.0.6".
warning " > @coreui/[email protected] /cdn-cgi/l/email-protection" has incorrect peer dependency "@coreui/coreui@^2.1.16".
warning " > @coreui/[email protected] /cdn-cgi/l/email-protection" has unmet peer dependency "mutationobserver-shim@^0.3.3".
warning " > @testing-library/[email protected] /cdn-cgi/l/email-protection" has unmet peer dependency "@testing-library/dom@>=5".
warning " > [email protected] /cdn-cgi/l/email-protection" has unmet peer dependency "classnames@^2.2.5".
warning " > [email protected] /cdn-cgi/l/email-protection" has unmet peer dependency "prop-types@^15.0.0".
warning "react-scripts > @typescript-eslint/eslint-plugin > [email protected] /cdn-cgi/l/email-protection" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.
6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] Building fresh packages...
[-/4] ⡀ waiting...
[-/4] ⡀ waiting...
[3/4] ⡀ node-sass
error C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass
Output:
Binary found at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass\vendor\win32-x64-72\binding.node
Testing binary
Binary has a problem: Error: Cannot find module './_baseClone'
Require stack:
- C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\lodash\cloneDeep.js
- C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass\lib\index.js
- C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass\scripts\build.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
    at Function.Module._load (internal/modules/cjs/loader.js:840:27)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\lodash\cloneDeep.js:1:17)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\Rahul\\yantra-front\\cargo_frontend\\cargo-app\\node_modules\\lodash\\cloneDeep.js',
    'C:\\Users\\Rahul\\yantra-front\\cargo_frontend\\cargo-app\\node_modules\\node-sass\\lib\\index.js',
    'C:\\Users\\Rahul\\yantra-front\\cargo_frontend\\cargo-app\\node_modules\\node-sass\\scripts\\build.js'
  ]
}
Building the binary locally
Building: C:\Program Files\nodejs\node.exe C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libs
ass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\Users\\Rahul\\yantra-front\\cargo_frontend\\cargo-app\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using [email protected] /cdn-cgi/l/email-protection
gyp info using [email protected] /cdn-cgi/l/email-protection | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:80:29)
gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\which\which.js:89:16
gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (fs.js:167:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Users\Rahul\AppData\Local\Programs\Python\Python37\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\Rahul\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:303:12)
gyp ERR! stack     at ChildProcess.emit (events.js:310:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Rahul\\yantra-front\\cargo_frontend\\cargo-app\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cfl
ags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\Rahul\yantra-front\cargo_frontend\cargo-app\node_modules\node-sass
gyp ERR! node -v v12.16.3
gyp ERR! node-gyp -v v3.8.0

而我的路径中有 python 3 和 2

C:\Python27;C:\Python27\Tools\Scripts
C:\Users\Rahul\.windows-build-tools\python27\
C:\Users\Rahul\AppData\Local\Programs\Python\Python37\
C:\Users\Rahul\AppData\Local\Programs\Python\Python37\Scripts\
C:\Users\Rahul\AppData\Roaming\npm
C:\Users\Rahul\AppData\Local\Yarn\bin
C:\Users\Rahul\AppData\Local\Microsoft\WindowsApps
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps

我无法运行该项目。请帮忙!!

包.json

{
  "name": "cargo-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@coreui/coreui": "^3.0.0",
    "@coreui/react": "^2.5.7",
    "@fortawesome/fontawesome-svg-core": "^1.2.28",
    "@fortawesome/free-solid-svg-icons": "^5.13.0",
    "@fortawesome/react-fontawesome": "^0.1.9",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "axios": "^0.19.2",
    "history": "^4.10.1",
    "node-sass": "^4.14.1",
    "react": "^16.13.1",
    "react-bootstrap-table-next": "^4.0.1",
    "react-dom": "^16.13.1",
    "react-redux": "^7.2.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.1",
    "react-toastify": "^6.0.0",
    "reactjs-localstorage": "^0.0.8",
    "reactstrap": "^8.4.1",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

此 Node 依赖项依赖于 Python 2,而它在您的计算机上找到的 Python 可执行文件是 Python 3。

你可以看到它试图print "%s.%s.%s"——这是Python 2语法,在Python 3中无效。

您的项目很可能依赖于旧版本的node-sass,而后者又依赖于过时版本的node-gyp。尝试在依赖项中指定较新版本的node-sass。

作为替代方案,您还可以尝试某人概述的解决方法这张票 https://github.com/sass/node-sass/issues/2827,将以下内容添加到您的 package.json 中:

  "resolutions": {
    "node-sass/node-gyp": "^6.0.0"
  },

不过,最好先看看是否可以切换到 Node-sass 的更新版本。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Yarn 安装抛出错误:gyp 动词 `which` 失败错误:未找到:python2 的相关文章

  • Node + Express 会话过期?

    我有一个 Express 应用程序 并且有一个登录表单 我需要持续 1 个月的会话 我是否将 maxAge 设置为一个月 以毫秒为单位 我让两台计算机保持打开状态并登录了 24 小时 当我回来时 两台计算机都已注销 我该如何解决这个问题 实
  • Redux 状态在 mapStateToProps 中未定义

    我目前正在关注this http teropa info blog 2015 09 10 full stack redux tutorial html教程 我遇到了一些障碍mapStateToProps在下面的代码中 import Reac
  • 仅显示某些路由的组件 - React

    我正在 React 中开发一个带有登录界面的网站 该网站显示一个自定义导航组件 但是我不希望它显示在主路线 即登录页面 上 但据我了解 静态组件不会在路线更改时重新呈现 这准确吗 我正在使用 React Router 来处理所有路由 这是我
  • ReferenceError:找不到变量:需要

    我在加载时遇到问题node modules到我的网页之一 我已经安装了 npm node js 并且我想使用require 函数在我的网站上初始化 Firebase 我不知道为什么 但它抛出引用错误 ReferenceError 找不到变量
  • ant-d upload中如何为removeFile添加PopConfirm一个图片文件

    我正在使用 Ant d Upload 通过本地系统上传文件 然后单击文件预览图像上的删除图标 图像文件将被删除 我想添加一个弹出确认 所以我尝试在 onRemovefunction 中添加确认作为承诺但它不起作用 它在浏览器中显示警报 on
  • 将 Sweet Alert 弹出窗口添加到 React 组件中的按钮

    我为 Bootstrap 和 React 找到了这个完美的 Sweet Alert 模块 我在 Meteor 应用程序中使用它 http djorg83 github io react bootstrap sweetalert http d
  • Flux + React.js - 操作中的回调是好还是坏?

    让我解释一下我最近遇到的问题 我有 React js Flux 驱动的应用程序 有一个列表显示文章数量 注意 应用程序中有多个不同的列表 和文章详情查看在里面 但每个列表只有一个 API 端点 它返回文章数组 为了显示我需要的详细信息fin
  • 如何访问另一个 mobx 商店中的 mobx 商店?

    假设以下结构 stores RouterStore js UserStore js index js each of Store jsfiles 是一个 mobx 存储类 包含 observable and action index js只
  • 如何将React版本17降级到16?

    由于 React 17 不支持许多 React 包 如何将 React 版本从 17 降级到 16 假设您使用 npm yarn 或其他节点包管理器 依赖项版本列在package json 搜索react and react dom包下de
  • React Native - 跨屏幕传递数据

    我遇到了一些麻烦react native应用程序 我不知道如何跨屏幕传递数据 我意识到还有其他类似的问题在 SO 上得到了回答 但是这些解决方案对我来说不起作用 我正在使用StackNavigator 这是我的设置App js file e
  • 使用Nodejs、Express和AngularJS在浏览器中显示IP

    我正在学习 Nodejs 和 ExpressJS 我正在尝试使用 ExpressJS 和 2 个节点模块 请求IP https www npmjs com package request ip and geoip2 https www np
  • 如何在 Node JS 应用程序中顺序启动两个命令

    我使用 mocha chai 为我的 Node js 应用程序编写了一些单元测试 我想通过package json文件的scripts属性依次启动node JS服务器和测试套件 我的节点版本是6 9 4 我的 package json 中的
  • 将 JavaScript 数组转换为具有属性的数组

    我有一个像这样的数组从服务器返回响应 111 1010 111 1010 1010 我想将其转换为 JavaScript JSON 如下所示 branch 111 branch 1010 branch 111 branch 1010 bra
  • 使用 enctype="multipart/form-data" 时出现 CSRF 错误

    每当我将 enctype multipart form data 添加到我的 html 表单中时 我得到ForbiddenError invalid csrf token 如果我删除 enctype 它就可以工作 我发送的 csrf 代码如
  • 如何在 Nodejs - mongodb 搜索中对结果进行排序,但是,通过调用动态方法

    我正在 Nodejs 中开发一个 Web 应用程序 通过 mongo 本机连接器连接到 mongodb 在我的一个 js 文件中 我有一个通用方法来调用 find 或 findOne 操作以从 mongodb 集合中检索我需要的任何内容 如
  • 如何使用 Passport /Facebook 策略/验证 Supertest 请求?

    我使用 Passport js 进行身份验证 Facebook 策略 并使用 Mocha 和 Supertest 进行测试 如何使用 Supertest for Facebook 策略创建会话并发出经过身份验证的请求 这是用户未登录时的示例
  • React.js 和 Ajax 之间的区别

    当我在 google 上搜索 React js 时 我得到的是 React js 是一个用于创建用户界面的框架 如果网站的某个特定部分经常更新 则意味着我们可以使用 React 但我很困惑 Ajax 仅用于此目的 我们可以使用 Ajax 更
  • React Context - Context.Consumer 与 Class.contextType

    我正在学习新引入的 React Context API 但我注意到它在示例中的消耗存在一些不一致 有的还是用原来的上下文 消费者HOC 方法 而有些 包括 React 文档 使用静态类 contextType method 有什么区别以及为
  • 为什么react中的组件需要大写? [复制]

    这个问题在这里已经有答案了 因此 当您声明一个组件以小写首字母进行反应时 它不会显示 也不会引发错误 当您将组件名称大写时 它确实有效 这样的实现是怎样的呢 为了避免与现有的 html 元素发生冲突 还是这是一个错误 var test Re
  • 带有 'as' 属性的通用 React TypeScript 组件(能够渲染任何有效的 dom 节点)

    我在下面的示例中按预期工作 我的问题是 无论如何我可以重写它 这样我就不必传递通用的T和as支柱 理想情况下我想通过asprop 并让组件的 prop 接口使用它 这在 TypeScript 中可能吗 export type Props l

随机推荐