Something went wrong installing the "sharp" module

Hello just want to ask a question as I’m still new to appium when I run my test I’m getting this error for appium:

e    [35m[Appium]e[39m Could not load driver 'uiautomator2', so it will not be available. Error in loading the driver was: 
e[35m[Appium]e[39m Something went wrong installing the "sharp" module
e[35m[Appium]e[39m 
e[35m[Appium]e[39m Cannot find module '../build/Release/sharp-darwin-x64.node'

which in return result to this:

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: An unknown server-side error occurred while processing the command. Original error: Could not find a driver for automationName 'UIAutomator2' and platformName 'ANDROID'. Have you installed a driver that supports those capabilities? Run 'appium driver list --installed' to see. (Lower-level error: 
Something went wrong installing the "sharp" module

This issue does not occur if I run appium normally from the terminal and appium is working find through the appium inspector when I start session

What I’ve tried:

  • Tried lowering appium version
  • reinstall appium
  • change permissions in of node_modules (Thought maybe its a permission issue)

Hope you can help me with this issue I don’t need sharp at the moment I don’t know why its installing during when I run the test. Thank you

I’m not understanding when the problem is occurring. Seems like it is working normally most times, what is the difference that makes the problem occur?

first link in google → Something went wrong installing the "sharp" module · Issue #24559 · gatsbyjs/gatsby · GitHub

try answer

npm rebuild --verbose sharp

Hello, sorry for the confusion the issue was that when I start appium via a ServerManager class it is trying to install sharp module for some reason

e[35m[Appium]e[39m { port: e[33m26280e[39m, sessionOverride: e[33mtruee[39m }

e[35m[Appium]e[39m Attempting to load driver uiautomator2...

[debug] e[35m[Appium]e[39m Requiring driver at /Users/cj/.appium/node_modules/appium-uiautomator2-driver

e[35m[Appium]e[39m Could not load driver 'uiautomator2', so it will not be available. Error in loading the driver was:

e[35m[Appium]e[39m Something went wrong installing the "sharp" module

e[35m[Appium]e[39m

e[35m[Appium]e[39m Cannot find module '../build/Release/sharp-darwin-x64.node'

But when I start Appium normally in the terminal it would run and wont install sharp

    [Appium] Welcome to Appium v2.0.0-rc.1
[Appium] Attempting to load driver uiautomator2...
[debug] [Appium] Requiring driver at /Users/cj/.appium/node_modules/appium-uiautomator2-driver
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLS in your client code to connect to this server:
[Appium] 	http://127.0.0.1:4723/
[Appium] 	http://192.168.254.202:4723/
[Appium] Available drivers:
[Appium]   - [email protected] (automationName 'UiAutomator2')
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.

Basically what I’m trying to do is start appium automatically but appium is trying to install a module when I run it automatically, is there any way I can disable/skip appium to make the installation of modules optional ex. sharp module

Thank you for the reply appreciate it

Hello Aleksei, thank you for the reply. I’ve also tried this command but still encountering the issue. I don’t know why appium is trying to install a module when I run automatically but when I run it manually via the appium command in the terminal it works fine.

ServerManager - is it some Java or ?

yes the ServerManager is coded in java

Not sure where its calling the sharp module here and why its also installing

I am starting appium with command like in terminal/command line.

never had any issues.

currently using ProcessBuilder but before used some other way which are tons in Java.

        // start Appium server
        List list = new ArrayList<String>();
        list.add("appium");
        list.add("--log-level");
        list.add(logLevel.level);
        list.add("--port");
        list.add(String.valueOf(ports.getServerPort()));
        list.add("--keep-alive-timeout");
        list.add("1800"); // 30 min
        list.add("--session-override");
        list.add("--log-timestamp");
        if (saveLogs != null && saveLogs.equalsIgnoreCase("true")) {
            list.add("-g");
            list.add("./target/" + deviceName + ".log");
        }
        list.add("--tmp");
        list.add(tmpFolder);
        list.add("--use-plugins");
        list.add("execute-driver");
        list.add("--relaxed-security"); // needed for performance record

        Logger.log("    start appium with: " + list);
        // create the process builder
        try {
            ProcessBuilder pb1 = new ProcessBuilder(list);
            // print inputStream to console
            pb1.redirectErrorStream(true);
            pb1.redirectOutput(ProcessBuilder.Redirect.INHERIT);
            appium_Process = pb1.start();
        } catch (Exception e) {
            Logger.logError("FAILED\n" + e.getMessage());
        }
        return appium_Process;

I have been facing same issue due to ‘sharp’ module when I try to launch appium server from mac terminal. Below are the things which I tried but doesn’t seems to be working for me

What I have tried:

  1. Uninstalling Appium v1.22.3 and then installing Appium 2.0
  2. Updating Node and Npm version to their latest versions.
  3. Appium server error says to install sharp using “npm install --platform=darwin --arch=x64 sharp” but after successful installation also I am getting same issue.
  4. Checked official sharp version to check the compatibility, it looks ok to me. https://sharp.pixelplumbing.com/install#prebuilt-binaries
  5. Tried to install sharp-cli. “npm i sharp-cli”.
  6. Tried to install sharp globally using admin account.
  7. Updated homebrew also ran brew upgrade.
  8. change permissions in of node_module

Exception:

manish@arya-MAC ~ % appium --use-driver uiautomator2
[Appium] Welcome to Appium v2.0.0-rc.3
[Appium] Non-default server args:
[Appium] {
[Appium] useDrivers: [
[Appium] ‘uiautomator2’
[Appium] ]
[Appium] }
[Appium] Attempting to load driver uiautomator2…
[debug] [Appium] Requiring driver at /Users/manish/.appium/node_modules/appium-uiautomator2-driver
[Appium] Could not load driver ‘uiautomator2’, so it will not be available. Error in loading the driver was:
[Appium] Something went wrong installing the “sharp” module
[Appium]
[Appium] Cannot find module ‘…/build/Release/sharp-darwin-x64.node’

adding info from running M2 macMini. just in case:

node - version
Welcome to Node.js v20.3.0.

appium -v
2.0.0-beta.66

appium driver list
✔ Listing available drivers
- [email protected] [installed (npm)]
- [email protected] [installed (npm)]

rc.1 got a hotfix to address this issue. Consider using rc.2 instead

Ok, I’ve never heard of ServerManager, and when I do a websearch there seem to be a lot of them. I’m not sure what ServerManager gives you, but I would look directly at how it is starting the Appium server, like what options is it using, etc. There is something different about the way it starts that I just can’t tell from your description. Enable logging if you can or run in verbose mode.

Thank you for the help on this issue, for now I’m running appium manually instead of implementing a servermanager to run appium automatically. Still not sure why this is happening. I’m using rc.3 of appium.

I have tried in rc.3 it didn’t work