The main Appium script does not exist at <...>

@Aleksei @wreed

I am using appium 2.0.0-beta.57.
Previously when I try to run appium server programmatically, node.js could not be found. So apart from node.js being installed by nvm, I additionally installed the same node.js from nodes.org web site and gave it’s path in the .zshrc, my profile file. Now a new error similar to the above is coming up:

io.appium.java_client.service.local.InvalidServerInstanceException: The main Appium script does not exist at '~//appium/build/lib/main.js

My server starting code is this …

public AppiumDriverLocalService GetAppiumService() {
GlobalParams params = new GlobalParams();
return AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
.usingAnyFreePort()
.withArgument(() → “–base-path”, “/wd/hub”)
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withLogFile(new File(params.getPlatformName() + “_”
+ params.getDeviceName() + File.separator + “Server.log”)));
}

When I run ‘appium-doctor’ it is reporting Diagnostic for necessary dependencies completed, no fix needed

When I run ‘which appium’ on the terminal, I get the path “~/.nvm/versions/node/v18.12.0/bin/appium”. I don’t understand why appium goes and installs under one of the node versions installed via nvm ???

As per my understanding, it should properly reside at ‘/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/main.js’.

Instead the appium.js file does exist at two places ~/node_modules/appium/build/lib and ~/node_modules/appium/lib

When I run ‘appium’ at the terminal, it’s output is

[Appium] Welcome to Appium v2.0.0-beta.57 (REV 4b947ec92d0195756709e5b563569cf48aef1e09)
[Appium] Attempting to load driver xcuitest…
[debug] [Appium] Requiring driver at /Users/venkatanutalapati/.appium/node_modules/appium-xcuitest-driver
[Appium] Attempting to load driver uiautomator2…
[debug] [Appium] Requiring driver at /Users/venkatanutalapati/.appium/node_modules/appium-uiautomator2-driver
[Appium] Attempting to load driver flutter…
[debug] [Appium] Requiring driver at /Users/venkatanutalapati/.appium/node_modules/appium-flutter-driver
[Appium] Attempting to load driver safari…
[debug] [Appium] Requiring driver at /Users/venkatanutalapati/.appium/node_modules/appium-safari-driver
[Appium] Attempting to load driver gecko…
[debug] [Appium] Requiring driver at /Users/venkatanutalapati/.appium/node_modules/appium-geckodriver
(node:29873) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use node --trace-warnings ... to show where the warning was created)
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[Appium] Available drivers:
[Appium] - [email protected] (automationName ‘XCUITest’)
[Appium] - [email protected] (automationName ‘UiAutomator2’)
[Appium] - [email protected] (automationName ‘Flutter’)
[Appium] - [email protected] (automationName ‘Safari’)
[Appium] - [email protected] (automationName ‘Gecko’)

Please help me correct the errors and run the appium programmatically.

last time I installed appium 3 days ago on M1 Macbook. I did just switch to bash in terminal and just corrected ADB paths for android in profile. sorry never used zsh yet :frowning:

If you installed with npm install appium@next -g command, then yes, it does install in Node.

That is the old server GUI. Currently there is not a GUI for Appium 2.

I think you have multiple versions installed. Not sure how they were installed but one might be in npm with -g option and one without. It’s possible that you have other installs.

That output looks fine.

Not seeing this in the output you posted. Maybe you start Appium another way? If not, can you post full log as a git gist?

appium 2 default path is empty, meaning just / and latest java-client versions assume the default path is without wd/hub so unless you specify it when initializing the driver you will get an error. would suggest to make sure you do pass the correct endpoint to appium driver or otherwise just remove this line.

Additionally, you can specify appiumJS as suggested here: io.appium.java_client.service.local.InvalidServerInstanceException: There is no installed nodes! · Issue #114 · appium/appium-docker-android · GitHub

And, if still nothing works for you, would suggest to uninstall appium, go to both paths and make sure they were deleted then, reinstall appium globally with npm(regular appium installation).

@ido_oserovitz @wreed @Aleksei
I basically solved the issue by uninstalling the nvm tool completely. And re installed the appium the latest one using npm, like npm install -g appium@next
Now my node(v18.15.0) is at /usr/local/bin/node. And appium(2.0.0-beta.57) is at /usr/local/bin/appium
These tools like nvm and SDKMan supposed to help switch between multiple installations of Java and node respectively, but some how, I don’t know why, they end up messing up the run time paths. A similar thing happened, and I have to uninstall SDKMan in the case of Java.
Thanks for the support.

2 Likes

@Venkata it’s true that a reinstall can fix a lot of issues that are really hard to troubleshoot. I’ve done plenty of reinstalls myself. I’m glad you were able to fix the problem and thanks for posting what worked for you.

2 Likes