Appium driver install fails while checking drivers compatibility

I’m following the steps of the Appium Quickstart, I got stuck while trying to install the uiautomator2 driver.

appium driver install uiautomator2

× Checking if 'appium-uiautomator2-driver' is compatible
Error: npm command 'info appium-uiautomator2-driver peerDependencies dependencies --json' failed with code EINVAL.

STDOUT:


STDERR:

I’m setting it up in Windows, the following versions are installed:
Node version: v20.12.2
npm version: 10.5.2
appium version: v2.5.2

It might be something specific to your system. Try to run npm info appium-uiautomator2-driver peerDependencies dependencies --json with verbose logging enabled to see the detailed error report

I have the same issue. While running

appium driver install uiautomator2

I get

× Checking if 'appium-uiautomator2-driver' is compatible
Error: npm command 'info appium-uiautomator2-driver peerDependencies dependencies --json' failed with code EINVAL.

STDOUT:


STDERR:

Though if I run

npm i appium-uiautomator2-driver

I get some kind of install process with this in the end:

up to date, audited 688 packages in 27s

68 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

But when I check with

appium driver list

I get thу message with no drivers are installed, even after reboot. And appium server fails to start with no uiautomator2 driver error.

I’m very lost at this point.

I’m on Windows,
npm version 10.5.2
appium version 2.5.2
node version 20.12.2

Is it a possible bug? I tried with previous versions of Appium and npm, also with newer node (current v21.7.3), nothing helped.

Here are the current system requirements:

Best advice is to downgrade node to 18 or below and npm to 8 or below.

Thanks for you answer!

I ran the npm command sent by the appium extension CLI. It runs successfully, as shown below. Given the command is successful a verbose log didn’t point to any possible root cause.

npm.cmd info appium-uiautomator2-driver peerDependencies dependencies --json
{
  "peerDependencies": {
    "appium": "^2.4.1"
  },
  "dependencies": {
    "appium-adb": "^12.0.0",
    "appium-android-driver": "^9.1.0",
    "appium-chromedriver": "^5.6.28",
    "appium-uiautomator2-server": "^7.0.1",
    "asyncbox": "^3.0.0",
    "axios": "^1.6.5",
    "bluebird": "^3.5.1",
    "css-selector-parser": "^3.0.0",
    "io.appium.settings": "^5.7.2",
    "lodash": "^4.17.4",
    "portscanner": "^2.2.0",
    "source-map-support": "^0.x",
    "teen_process": "^2.0.0",
    "type-fest": "^4.4.0"
  }
}

I have the exact same problem.
Running npm info appium-uiautomator2-driver peerDependencies dependencies --json works.

npm verb cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
npm info using [email protected]
npm info using [email protected]
npm verb title npm info appium-uiautomator2-driver peerDependencies dependencies
npm verb argv "info" "appium-uiautomator2-driver" "peerDependencies" "dependencies" "--json" "--loglevel" "verbose"
npm verb logfile logs-max:10 dir:C:\Users\user\AppData\Local\npm-cache\_logs\2024-04-11T16_06_41_728Z-
npm verb logfile C:\Users\user\AppData\Local\npm-cache\_logs\2024-04-11T16_06_41_728Z-debug-0.log
npm http fetch GET 200 https://registry.npmjs.org/appium-uiautomator2-driver 255ms (cache revalidated)
{
  "peerDependencies": {
    "appium": "^2.4.1"
  },
  "dependencies": {
    "appium-adb": "^12.0.0",
    "appium-android-driver": "^9.1.0",
    "appium-chromedriver": "^5.6.28",
    "appium-uiautomator2-server": "^7.0.1",
    "asyncbox": "^3.0.0",
    "axios": "^1.6.5",
    "bluebird": "^3.5.1",
    "css-selector-parser": "^3.0.0",
    "io.appium.settings": "^5.7.2",
    "lodash": "^4.17.4",
    "portscanner": "^2.2.0",
    "source-map-support": "^0.x",
    "teen_process": "^2.0.0",
    "type-fest": "^4.4.0"
  }
}
npm verb exit 0
npm info ok

OS: Windows 11 Pro (22631.3447)
Appium version: 2.5.2
Node.js version: v20.12.2
npm version: 10.5.0

I downgraded Appium, Node.js and npm, but the error wouldn’t change.

Appium version: 2.4.1
Node.js version: v18.20.2
npm version: 8.19.4

✖ Checking if 'appium-uiautomator2-driver' is compatible
Error: npm command 'info appium-uiautomator2-driver peerDependencies dependencies --json' failed with code EINVAL.

STDOUT:


STDERR:

The log of npm info appium-uiautomator2-driver peerDependencies dependencies --json is as follows.

npm verb cli C:\Program Files\nodejs\node.exe C:\Users\user\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
npm info using [email protected]
npm info using [email protected]
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 2ms
npm timing config:load:file:C:\Users\user\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 2ms
npm timing config:load:builtin Completed in 2ms
npm timing config:load:cli Completed in 2ms
npm timing config:load:env Completed in 1ms
npm timing config:load:project Completed in 1ms
npm timing config:load:file:C:\Users\user\.npmrc Completed in 0ms
npm timing config:load:user Completed in 0ms
npm timing config:load:file:C:\Users\user\AppData\Roaming\npm\etc\npmrc Completed in 0ms
npm timing config:load:global Completed in 0ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 1ms
npm timing config:load:setEnvs Completed in 1ms
npm timing config:load Completed in 11ms
npm timing npm:load:configload Completed in 11ms
npm timing npm:load:mkdirpcache Completed in 1ms
npm timing npm:load:mkdirplogs Completed in 0ms
npm verb title npm info appium-uiautomator2-driver peerDependencies dependencies
npm verb argv "info" "appium-uiautomator2-driver" "peerDependencies" "dependencies" "--json" "--loglevel" "verbose"
npm timing npm:load:setTitle Completed in 1ms
npm timing config:load:flatten Completed in 4ms
npm timing npm:load:display Completed in 16ms
npm verb logfile logs-max:10 dir:C:\Users\user\AppData\Local\npm-cache\_logs
npm verb logfile C:\Users\user\AppData\Local\npm-cache\_logs\2024-04-11T16_22_40_352Z-debug-0.log
npm timing npm:load:logFile Completed in 10ms
npm timing npm:load:timers Completed in 0ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 43ms
npm http fetch GET 200 https://registry.npmjs.org/appium-uiautomator2-driver 261ms (cache miss)
{
  "peerDependencies": {
    "appium": "^2.4.1"
  },
  "dependencies": {
    "appium-adb": "^12.0.0",
    "appium-android-driver": "^9.1.0",
    "appium-chromedriver": "^5.6.28",
    "appium-uiautomator2-server": "^7.0.1",
    "asyncbox": "^3.0.0",
    "axios": "^1.6.5",
    "bluebird": "^3.5.1",
    "css-selector-parser": "^3.0.0",
    "io.appium.settings": "^5.7.2",
    "lodash": "^4.17.4",
    "portscanner": "^2.2.0",
    "source-map-support": "^0.x",
    "teen_process": "^2.0.0",
    "type-fest": "^4.4.0"
  }
}
npm timing command:info Completed in 298ms
npm verb exit 0
npm timing npm Completed in 358ms
npm info ok

Thanks for the answer! On the link you provided it’s stated >=8 npm, which is over 8 version, and over 18 node?

Yeah, it’s confusing. I unfortunately don’t have Windows, so can’t reproduce.

FWIW, I’m currently running (on a Mac):
node -v
v16.13.0
npm -v
8.1.0
appium -v
2.4.1

I’m using NVM to manage my node installations. I hope that helps someone.

1 Like

Try to enable verbose npm logging globally and retry the command (npm config set loglevel verbose)

How about this?

PS C:\Users\user> npm config set loglevel verbose
PS C:\Users\user> npm info appium-uiautomator2-driver peerDependencies dependencies --json
npm verb cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
npm info using [email protected]
npm info using [email protected]
npm verb title npm prefix
npm verb argv "prefix" "--global"
npm verb logfile logs-max:10 dir:C:\Users\user\AppData\Local\npm-cache\_logs\2024-04-11T21_50_20_207Z-
npm verb logfile C:\Users\user\AppData\Local\npm-cache\_logs\2024-04-11T21_50_20_207Z-debug-0.log
npm verb exit 0
npm info ok
npm verb cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
npm info using [email protected]
npm info using [email protected]
npm verb title npm info appium-uiautomator2-driver peerDependencies dependencies
npm verb argv "info" "appium-uiautomator2-driver" "peerDependencies" "dependencies" "--json"
npm verb logfile logs-max:10 dir:C:\Users\user\AppData\Local\npm-cache\_logs\2024-04-11T21_50_20_593Z-
npm verb logfile C:\Users\user\AppData\Local\npm-cache\_logs\2024-04-11T21_50_20_593Z-debug-0.log
npm http fetch GET 200 https://registry.npmjs.org/appium-uiautomator2-driver 805ms (cache miss)
{
  "peerDependencies": {
    "appium": "^2.4.1"
  },
  "dependencies": {
    "appium-adb": "^12.0.0",
    "appium-android-driver": "^9.1.0",
    "appium-chromedriver": "^5.6.28",
    "appium-uiautomator2-server": "^7.0.1",
    "asyncbox": "^3.0.0",
    "axios": "^1.6.5",
    "bluebird": "^3.5.1",
    "css-selector-parser": "^3.0.0",
    "io.appium.settings": "^5.7.2",
    "lodash": "^4.17.4",
    "portscanner": "^2.2.0",
    "source-map-support": "^0.x",
    "teen_process": "^2.0.0",
    "type-fest": "^4.4.0"
  }
}
npm verb exit 0
npm info ok

I wonder why appium command catches EINVAL while manual npm throws no errors…

I have the exact same issue when installing appium windows native driver

appium driver install --source=npm appium-windows-driver
× Checking if 'appium-windows-driver' is compatible
Error: npm command 'info appium-windows-driver peerDependencies dependencies --json' failed with code EINVAL.

STDOUT:


STDERR:

and here is what I get on running the info command manually

npm info appium-windows-driver peerDependencies dependencies --json
npm verb cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
npm info using [email protected]
npm info using [email protected]
npm verb title npm prefix
npm verb argv "prefix" "--global"
npm verb logfile logs-max:10 dir:C:\Users\Srijan\AppData\Local\npm-cache\_logs\2024-04-12T00_56_52_598Z-
npm verb logfile C:\Users\xyz\AppData\Local\npm-cache\_logs\2024-04-12T00_56_52_598Z-debug-0.log
npm verb exit 0
npm info ok
npm verb cli C:\Program Files\nodejs\node.exe C:\Users\xyz\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
npm info using [email protected]
npm info using [email protected]
npm verb title npm info appium-windows-driver peerDependencies dependencies
npm verb argv "info" "appium-windows-driver" "peerDependencies" "dependencies" "--json"
npm verb logfile logs-max:10 dir:C:\Users\xyz\AppData\Local\npm-cache\_logs\2024-04-12T00_56_52_949Z-
npm verb logfile C:\Users\xyz\AppData\Local\npm-cache\_logs\2024-04-12T00_56_52_949Z-debug-0.log
npm http fetch GET 200 https://registry.npmjs.org/appium-windows-driver 125ms (cache revalidated)
{
  "peerDependencies": {
    "appium": "^2.4.0"
  },
  "dependencies": {
    "asyncbox": "^3.0.0",
    "bluebird": "^3.5.1",
    "fancy-log": "^2.0.0",
    "lodash": "^4.6.1",
    "portscanner": "^2.2.0",
    "source-map-support": "^0.x",
    "teen_process": "^2.0.1"
  }
}

I am running Appium version 2.5.2

1 Like

I set npm loglevel to verbose. Running the npm command works well and I get the same output as you.

When using the appium extension cli I get the EINVAL error but unfortunately no npm logfiles are generated. I checked the logfiles in the npm-cache/_logs dir.

I was able to make it work. It seems there is some error related to the shell used to execute the command. In order to make it work I manually edited the file located at:

C:Users\user\AppData\Roaming\npm\node_modules\appium\node_modules\teen_process\build\lib\exec.js

And changed the shell to be true instead of undefined like so:

    opts = /** @type {T} */ (lodash_1.default.defaults(opts, {
        timeout: null,
        encoding: 'utf8',
        killSignal: 'SIGTERM',
        cwd: undefined,
        env: process.env,
        ignoreOutput: false,
        stdio: 'inherit',
        isBuffer: false,
        shell: true,
        logger: undefined,
        maxStdoutBufferSize: MAX_BUFFER_SIZE,
        maxStderrBufferSize: MAX_BUFFER_SIZE,
    }));
5 Likes

It works, thank you so much!

1 Like

That’s an interesting hack. It might break other commands though as the shell option is going to be enabled for all commands going through teen_process. I’ve pushed a patch for this particular issue, but it is only going to be published with the next server version

2 Likes

Worked for me, thanks a lot!

Thank you, it works for me in windows:
C:\Windows\system32>node -v
v16.20.2

C:\Windows\system32>npm -v
8.19.4

C:\Windows\system32>appium -v
2.4.1

I follow other guides but only this works, just install the version like this.

2 Likes

It works for me, thank you so much!