Appium 在用 appium2.0 安装驱动时总是出现这个错误

skyshine · 2023年08月17日 · 最后由 YesterDayOnceMore 回复于 2024年02月21日 · 6276 次阅读

在用 appium2 安装驱动时总是出现这个错误
安装 appium driver install uiautomator2 时也有好多次,但不知道怎么了,又好了。
但装 chromium 驱动时又出来了,这倒底是什么原因啊?
谢谢

PS C:\Users\xx> appium driver install chromium
× Installing 'chromium' using NPM install spec 'appium-chromium-driver'
Error: × Encountered an error when installing package: npm command 'install --save-dev appium-chromium-driver --json' failed with code 1.

STDOUT:
{
  "error": {
    "code": 1,
    "summary": "command failed",
    "detail": "C:\\WINDOWS\\system32\\cmd.exe /d /s /c node install-npm.js\n[22:03:41] Error installing Chromedriver: read ECONNRESET\n[22:03:41] Error: read ECONNRESET\n    at Function.AxiosError.from (C:\\Users\\ty\\node_modules\\appium-chromium-driver\\node_modules\\axios\\lib\\core\\AxiosError.js:89:14)\n    at RedirectableRequest.handleRequestError (C:\\Users\\ty\\node_modules\\appium-chromium-driver\\node_modules\\axios\\lib\\adapters\\http.js:591:25)\n    at RedirectableRequest.emit (node:events:526:35)\n    at ClientRequest.eventHandlers.<computed> (C:\\Users\\ty\\node_modules\\appium-chromium-driver\\node_modules\\follow-redirects\\index.js:14:24)\n    at ClientRequest.emit (node:events:514:28)\n    at TLSSocket.socketErrorListener (node:_http_client:495:9)\n    at TLSSocket.emit (node:events:514:28)\n    at emitErrorNT (node:internal/streams/destroy:151:8)\n    at emitErrorCloseNT (node:internal/streams/destroy:116:3)\n    at processTicksAndRejections (node:internal/process/task_queues:82:21)\n[22:03:41] Downloading Chromedriver can be skipped by setting the'APPIUM_SKIP_CHROMEDRIVER_INSTALL' environment variable."
  }
}

STDERR:
npm WARN deprecated typedoc-plugin-resolve-crossmodule-references@0.3.3: Upgrade to typedoc >= 0.24 and remove typedoc-plugin-resolve-crossmodule-references from your dependencies
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN cleanup Failed to remove some directories [
npm WARN cleanup   [
npm WARN cleanup     'C:\\Users\\ty\\node_modules\\appium-chromium-driver\\node_modules\\appium',
npm WARN cleanup     [Error: EBUSY: resource busy or locked, rmdir 'C:\Users\ty\node_modules\appium-chromium-driver\node_modules\appium'] {
npm WARN cleanup       errno: -4082,
npm WARN cleanup       code: 'EBUSY',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\Users\\ty\\node_modules\\appium-chromium-driver\\node_modules\\appium'
npm WARN cleanup     }
npm WARN cleanup   ],
npm WARN cleanup   [
npm WARN cleanup     'C:\\Users\\ty\\node_modules\\appium-chromium-driver\\node_modules',
npm WARN cleanup     [Error: EBUSY: resource busy or locked, rmdir 'C:\Users\ty\node_modules\appium-chromium-driver\node_modules\appium'] {
npm WARN cleanup       errno: -4082,
npm WARN cleanup       code: 'EBUSY',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\Users\\ty\\node_modules\\appium-chromium-driver\\node_modules\\appium'
npm WARN cleanup     }
npm WARN cleanup   ],
npm WARN cleanup   [
npm WARN cleanup     'C:\\Users\\ty\\node_modules\\appium-chromium-driver',
npm WARN cleanup     [Error: EBUSY: resource busy or locked, rmdir 'C:\Users\ty\node_modules\appium-chromium-driver\node_modules\appium'] {
npm WARN cleanup       errno: -4082,
npm WARN cleanup       code: 'EBUSY',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\Users\\ty\\node_modules\\appium-chromium-driver\\node_modules\\appium'
npm WARN cleanup     }
npm WARN cleanup   ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path C:\Users\ty\node_modules\appium-chromium-driver\node_modules\appium-chromedriver
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install-npm.js
npm ERR! [22:03:41] Error installing Chromedriver: read ECONNRESET
npm ERR! [22:03:41] Error: read ECONNRESET
npm ERR!     at Function.AxiosError.from (C:\Users\ty\node_modules\appium-chromium-driver\node_modules\axios\lib\core\AxiosError.js:89:14)
npm ERR!     at RedirectableRequest.handleRequestError (C:\Users\ty\node_modules\appium-chromium-driver\node_modules\axios\lib\adapters\http.js:591:25)
npm ERR!     at RedirectableRequest.emit (node:events:526:35)
npm ERR!     at ClientRequest.eventHandlers.<computed> (C:\Users\ty\node_modules\appium-chromium-driver\node_modules\follow-redirects\index.js:14:24)
npm ERR!     at ClientRequest.emit (node:events:514:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:495:9)
npm ERR!     at TLSSocket.emit (node:events:514:28)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:82:21)
npm ERR! [22:03:41] Downloading Chromedriver can be skipped by setting the'APPIUM_SKIP_CHROMEDRIVER_INSTALL' environment variable.

npm ERR! A complete log of this run can be found in: F:\nodejs\node_cache\_logs\2023-08-17T14_00_59_110Z-debug-0.log
共收到 7 条回复 时间 点赞

Error installing Chromedriver: read ECONNRESET

看报错,原因是下载 chromedriver 时网络请求失败了。检查下你的网络是否可以正常下载 chromedriver?

如果不行,可以通过设置 APPIUM_SKIP_CHROMEDRIVER_INSTALL 这个环境变量,让程序自动判定为跳过下载 chromedriver 步骤。

陈恒捷 回复
PS C:\Users\ty> appium driver install uiautomator2
× Installing 'uiautomator2' using NPM install spec 'appium-uiautomator2-driver'
Error: × Encountered an error when installing package: npm command 'install --save-dev --omit=peer --save-exact --global-style --no-package-lock appium-uiautomator2-driver --json' failed with code 1.

STDOUT:
{
  "error": {
    "code": 1,
    "summary": "command failed",
    "detail": "C:\\WINDOWS\\system32\\cmd.exe /d /s /c node install-npm.js\n[10:39:28] Error installing Chromedriver: read ECONNRESET\n[10:39:29] Error: read ECONNRESET\n    at Function.AxiosError.from (C:\\Users\\ty\\.appium\\node_modules\\appium-uiautomator2-driver\\node_modules\\axios\\lib\\core\\AxiosError.js:89:14)\n    at RedirectableRequest.handleRequestError (C:\\Users\\ty\\.appium\\node_modules\\appium-uiautomator2-driver\\node_modules\\axios\\lib\\adapters\\http.js:591:25)\n    at RedirectableRequest.emit (node:events:526:35)\n    at ClientRequest.eventHandlers.<computed> (C:\\Users\\ty\\.appium\\node_modules\\appium-uiautomator2-driver\\node_modules\\follow-redirects\\index.js:14:24)\n    at ClientRequest.emit (node:events:514:28)\n    at TLSSocket.socketErrorListener (node:_http_client:495:9)\n    at TLSSocket.emit (node:events:514:28)\n    at emitErrorNT (node:internal/streams/destroy:151:8)\n    at emitErrorCloseNT (node:internal/streams/destroy:116:3)\n    at processTicksAndRejections (node:internal/process/task_queues:82:21)\n[10:39:29] Downloading Chromedriver can be skipped by setting the'APPIUM_SKIP_CHROMEDRIVER_INSTALL' environment variable."
  }
}

STDERR:
npm WARN config global-style This option has been deprecated in favor of `--install-strategy=shallow`
npm WARN cleanup Failed to remove some directories [
npm WARN cleanup   [
npm WARN cleanup     'C:\\Users\\ty\\.appium\\node_modules\\appium-uiautomator2-driver\\node_modules\\source-map',
npm WARN cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\ty\.appium\node_modules\appium-uiautomator2-driver\node_modules\source-map'] {
npm WARN cleanup       errno: -4048,
npm WARN cleanup       code: 'EPERM',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\Users\\ty\\.appium\\node_modules\\appium-uiautomator2-driver\\node_modules\\source-map'
npm WARN cleanup     }
npm WARN cleanup   ],
npm WARN cleanup   [
npm WARN cleanup     'C:\\Users\\ty\\.appium\\node_modules\\appium-uiautomator2-driver',
npm WARN cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\ty\.appium\node_modules\appium-uiautomator2-driver\node_modules\ncp\test\symlink-fixtures\src'] {
npm WARN cleanup       errno: -4048,
npm WARN cleanup       code: 'EPERM',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\Users\\ty\\.appium\\node_modules\\appium-uiautomator2-driver\\node_modules\\ncp\\test\\symlink-fixtures\\src'
npm WARN cleanup     }
npm WARN cleanup   ],
npm WARN cleanup   [
npm WARN cleanup     'C:\\Users\\ty\\.appium\\node_modules\\appium-uiautomator2-driver',
npm WARN cleanup     [Error: EPERM: operation not permitted, rmdir 'C:\Users\ty\.appium\node_modules\appium-uiautomator2-driver\node_modules\prebuild-install\node_modules\tar-fs\test'] {
npm WARN cleanup       errno: -4048,
npm WARN cleanup       code: 'EPERM',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: 'C:\\Users\\ty\\.appium\\node_modules\\appium-uiautomator2-driver\\node_modules\\prebuild-install\\node_modules\\tar-fs\\test'
npm WARN cleanup     }
npm WARN cleanup   ]
npm WARN cleanup ]
npm ERR! code 1
npm ERR! path C:\Users\ty\.appium\node_modules\appium-uiautomator2-driver\node_modules\appium-chromedriver
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node install-npm.js
npm ERR! [10:39:28] Error installing Chromedriver: read ECONNRESET
npm ERR! [10:39:29] Error: read ECONNRESET
npm ERR!     at Function.AxiosError.from (C:\Users\ty\.appium\node_modules\appium-uiautomator2-driver\node_modules\axios\lib\core\AxiosError.js:89:14)
npm ERR!     at RedirectableRequest.handleRequestError (C:\Users\ty\.appium\node_modules\appium-uiautomator2-driver\node_modules\axios\lib\adapters\http.js:591:25)
npm ERR!     at RedirectableRequest.emit (node:events:526:35)
npm ERR!     at ClientRequest.eventHandlers.<computed> (C:\Users\ty\.appium\node_modules\appium-uiautomator2-driver\node_modules\follow-redirects\index.js:14:24)
npm ERR!     at ClientRequest.emit (node:events:514:28)
npm ERR!     at TLSSocket.socketErrorListener (node:_http_client:495:9)
npm ERR!     at TLSSocket.emit (node:events:514:28)
npm ERR!     at emitErrorNT (node:internal/streams/destroy:151:8)
npm ERR!     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:82:21)
npm ERR! [10:39:29] Downloading Chromedriver can be skipped by setting the'APPIUM_SKIP_CHROMEDRIVER_INSTALL' environment variable.

npm ERR! A complete log of this run can be found in: C:\Users\ty\AppData\Local\npm-cache\_logs\2023-08-18T02_37_57_719Z-debug-0.log

这里上面写着:
when installing package: npm command 'install --save-dev --omit=peer --save-exact --global-style --no-package-lock appium-uiautomator2-driver --json' failed with code 1.

但下面还是有句 chromedriver 错误。这是哪个问题?


appium2 现在好麻烦,不如以前的呢。安装全靠运气。 我翻墙都还是这个错误。
真是不理解怎么回事?

有类似 appium2 的替代工具吗

skyshine 回复

when installing package: npm command 'install --save-dev --omit=peer --save-exact --global-style --no-package-lock appium-uiautomator2-driver --json' failed with code 1.

这个是最表面的问题,只要程序运行不正常,都会 with code 1 。但要知道具体什么原因引起,得看下面详细日志。从你给的日志看,根本问题是底下的 Error installing Chromedriver: read ECONNRESET

应该是网络问题,我也遇到过,隔了一天再安装刷刷刷地就安装好了

我今天安装成功了,弄了很久,在换成 node20.9.0 后奇迹般的安装成功了
尝试添加环境变量 APPIUM_SKIP_CHROMEDRIVER_INSTALL 的值为 1,似乎没什么效果
发现 appium 的安装路径为 C:\Users\Administrator.appium\node_modules
通过 npm 安装 appium-uiautomator2-driver 时很容易的
不知道手动往这个 appium 的安装路径拖拽一个 appium-uiautomator2-driver 文件夹是否有效
后面的同学可以尝试一下

不能在 C 盘的目录下载,要在项目文件目录打开 cmd,安装

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册