Appium driver install uiautomator2 can't install

Hi. When I try to install uiautomator2 on Mac I have this error

appium driver install uiautomator2
info Appium Setting NODE_PATH to '/usr/local/lib/node_modules'
✖ 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.


npm ERR! code 1
npm ERR! path /Users/a.vukovic/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver
npm ERR! command failed
npm ERR! command sh -c node install-npm.js
npm ERR! internal/modules/cjs/loader.js:638
npm ERR!     throw err;
npm ERR!     ^
npm ERR! 
npm ERR! Error: Cannot find module 'fs/promises'
npm ERR!     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
npm ERR!     at Function.Module._load (internal/modules/cjs/loader.js:562:25)
npm ERR!     at Module.require (internal/modules/cjs/loader.js:692:17)
npm ERR!     at require (internal/modules/cjs/helpers.js:25:18)
npm ERR!     at Object.<anonymous> (/Users/a.vukovic/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/install-npm.js:20:12)
npm ERR!     at Module._compile (internal/modules/cjs/loader.js:778:30)
npm ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
npm ERR!     at Module.load (internal/modules/cjs/loader.js:653:32)
npm ERR!     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
npm ERR!     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
npm ERR!     at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
npm ERR!     at startup (internal/bootstrap/node.js:283:19)
npm ERR!     at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
  "error": {
    "code": 1,
    "summary": "command failed",
    "detail": "sh -c node install-npm.js\ninternal/modules/cjs/loader.js:638\n    throw err;\n    ^\n\nError: Cannot find module 'fs/promises'\n    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)\n    at Function.Module._load (internal/modules/cjs/loader.js:562:25)\n    at Module.require (internal/modules/cjs/loader.js:692:17)\n    at require (internal/modules/cjs/helpers.js:25:18)\n    at Object.<anonymous> (/Users/a.vukovic/.appium/node_modules/appium-uiautomator2-driver/node_modules/appium-chromedriver/install-npm.js:20:12)\n    at Module._compile (internal/modules/cjs/loader.js:778:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)\n    at Module.load (internal/modules/cjs/loader.js:653:32)\n    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)\n    at Function.Module._load (internal/modules/cjs/loader.js:585:3)\n    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)\n    at startup (internal/bootstrap/node.js:283:19)\n    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)"

I tried to delete .appium and .npm folder and to install again, but I have the same error

node v17.4.0
appium 2.0.0-beta.44

appium doctor
WARN AppiumDoctor [Deprecated] Please use appium-doctor installed with “npm install @appium/doctor --location=global”
info AppiumDoctor Appium Doctor v.1.16.2
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor :heavy_check_mark: The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor :heavy_check_mark: Node version is 17.4.0
info AppiumDoctor :heavy_check_mark: Xcode is installed at: /Applications/
info AppiumDoctor :heavy_check_mark: Xcode Command Line Tools are installed in: /Applications/
info AppiumDoctor :heavy_check_mark: DevToolsSecurity is enabled.
info AppiumDoctor :heavy_check_mark: The Authorization DB is set up properly.
info AppiumDoctor :heavy_check_mark: Carthage was found at: /opt/homebrew/bin/carthage. Installed version is: 0.38.0
info AppiumDoctor :heavy_check_mark: HOME is set to: /Users/a.vukovic
info AppiumDoctor :heavy_check_mark: ANDROID_HOME is set to: /Users/a.vukovic/Library/Android/sdk
’ but this is NOT a valid path!is set to '/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home
info AppiumDoctor Checking adb, android, emulator, apkanalyzer
info AppiumDoctor ‘adb’ is in /Users/a.vukovic/Library/Android/sdk/platform-tools/adb
info AppiumDoctor ‘android’ is in /Users/a.vukovic/Library/Android/sdk/tools/android
info AppiumDoctor ‘emulator’ is in /Users/a.vukovic/Library/Android/sdk/emulator/emulator
info AppiumDoctor ‘apkanalyzer’ is in /Users/a.vukovic/Library/Android/sdk/tools/bin/apkanalyzer
info AppiumDoctor :heavy_check_mark: adb, android, emulator, apkanalyzer exist: /Users/a.vukovic/Library/Android/sdk
'. Is $JAVA_HOME set to a proper value?es not exist under '/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home

why are you manually installing the driver?

How should I do it? I actually need image recognition.

What tutorial are you following?

1 Like

Seems like a Node issue. I’ve found this StackOverflow post, does it help?

Thanks for posting the tutorials. The first one in particular is a must read for me.

Thank you for replying. How should I do it?