Getting Error While Launching Appium server Pragmatically but it getting started Manual hitting the command

Appium was getting stared when I hit appium Command In terminal But while starting from server I’m getting below Error.

Exception in thread “main” io.appium.java_client.service.local.InvalidServerInstanceException: Invalid server instance exception has occured: There is no installed nodes! Please install node via NPM (https://www.npmjs.com/package/appium#using-node-js) or download and install Appium app (http://appium.io/downloads.html)

Node Is Installed in my system Via Brew

Why It is working when i start from terminal but not getting started through Code

@mykola-mokhnach @Aleksei @rgonalo Please help me to rectify this.

share the code which you are using to start appium service.

Below Is the Following Code:
private AppiumDriverLocalService service;
private AppiumServiceBuilder builder;
private DesiredCapabilities cap;

public void startServer() {
	//Set Capabilities
	cap = new DesiredCapabilities();
	cap.setCapability("noReset", "false");
	
	//Build the Appium service
	builder = new AppiumServiceBuilder();
	builder.withIPAddress("127.0.0.0");
	builder.usingPort(4723);
	builder.withCapabilities(cap);
	builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
	builder.withArgument(GeneralServerFlag.LOG_LEVEL,"error");
	
	//Start the server with the builder
	service = AppiumDriverLocalService.buildService(builder);
	service.start();
}

try the buildDefaultService(), to check if default appium service is working.
AppiumDriverLocalService service
service = AppiumDriverLocalService.buildDefaultService();
service.start();

I’ve already tried this ,it also giving me the Same Error.
io.appium.java_client.service.local.InvalidServerInstanceException: Invalid server instance exception has occured: There is no installed nodes!

I’m guessing it could be a Path Problem,which i’m not getting exactly where is the mess

to me it looks a permission issue, uninstall node and reinstall without using sudo or you can give the node path to Appium service builder.

take a look at AppiumServiceBuilder class in java client, also i checked path on my machine it shows /usr/local/bin/node

public final class AppiumServiceBuilder extends Builder<AppiumDriverLocalService, AppiumServiceBuilder> {
public static final String APPIUM_PATH = “APPIUM_BINARY_PATH”;
public static final String NODE_PATH = “NODE_BINARY_PATH”;
public static final String DEFAULT_LOCAL_IP_ADDRESS = “0.0.0.0”;
private static final List PATH_CAPABILITIES = ImmutableList.of(“keystorePath”, “chromedriverExecutable”, “app”);
private static final String APPIUM_FOLDER = “appium”;
private static final String BUILD_FOLDER = “build”;
private static final S

@Tahir_Akhlaq i am installing appium with “npm”. and i start appium using any java executor and “appium” command.

You have to set the environment variables in Eclipse:

@wreed Still getting the same error.
Why it’s working fine while starting manually.

Ahh…I remember used to get these errors in eclipse, it would not even recognise adb. Intellij Works like a charm !!

so i should try in Intellij??

Give a try, that should resolve the issue.

Getting the same Error On Intellij Too ! @venkatesh

@Tahir_Akhlaq

Try installing node from https://nodejs.org/en/download/
and then give another run.

2 REALLY BIG problems with your setup.

  1. NODE_HOME. Really? Where did this come from? I think you should add node’s location to your PATH variable. I did a quick search for NODE_HOME and couldn’t find any reference to that. Don’t just make stuff up and expect it to work.
  2. /usr/bin/node. That is not the path. When giving a path you only need to specify the directory node is inside of. So if it’s really inside /usr/bin, that’s all you should need. However, on my Mac the path is /usr/local/bin/node, which would make the path /usr/local/bin <-you can find where node lives by typing: which node in the terminal.

If you don’t understand environment variables please read this:

http://www.linfo.org/path_env_var.html

2 Likes

thanks buddy :slight_smile:

@wreed @Aleksei

I am facing the same/similar issue.
I am using IntelliJ IDEA 2022.1.4 (Community Edition)
Which node returns: /Users/venkatanutalapati/.nvm/versions/node/v18.12.0/bin/node
I defined a variable NODE_PATH=/Users/venkatanutalapati/.nvm/versions/node/v18.12.0/bin
and my path:
export PATH=/bin:/usr/bin:/usr/local/bin:${NODE_PATH}:/usr/sbin:/sbin:/usr/local/bin/appium:${JAVA_HOME}/bin:${GRADLE_HOME}/bin:$PATH

I am trying to start the appium programmatically like 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”)));
* }

I am getting the following error when I run my testing.xml file

io.appium.java_client.service.local.InvalidServerInstanceException: NodeJS is either not installed or its executable not present in PATH

  • at io.appium.java_client.service.local.AppiumServiceBuilder.validatePath(AppiumServiceBuilder.java:124)*
  • at io.appium.java_client.service.local.AppiumServiceBuilder.findBinary(AppiumServiceBuilder.java:134)*
  • at io.appium.java_client.service.local.AppiumServiceBuilder.findDefaultExecutable(AppiumServiceBuilder.java:177)*
  • at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:456)*
  • at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:90)*
  • at utils.ServerManager.GetAppiumService(ServerManager.java:38)*

BTW, my appium version is [email protected]
Please help, where I am making the mistake.

Error gone:
Sometimes, when using Node Version Manager like nvm being used to install and maintain node and npm , you may need to download and install the same or higher version of node/npm being downloaded(in pkg form) from nodejs.org.

But new error came up, which is posted here

After trying all the suggestions in this thread , I am still getting the same error.

My Set up is:

  • Mac M1 OS:14.1.2
  • Appium 2.2.2 (/opt/homebrew/lib/node_modules/appium/build//lib/main.js)
  • Java 21.0.1
  • Node v21.2.0
Exception in thread "main" io.appium.java_client.service.local.InvalidServerInstanceException: NodeJS is either not installed or its executable not present in PATH
	at io.appium.java_client.service.local.AppiumServiceBuilder.validatePath(AppiumServiceBuilder.java:127)
	at io.appium.java_client.service.local.AppiumServiceBuilder.findBinary(AppiumServiceBuilder.java:137)
	at io.appium.java_client.service.local.AppiumServiceBuilder.findDefaultExecutable(AppiumServiceBuilder.java:179)
	at io.appium.java_client.service.local.AppiumServiceBuilder.loadSystemProperties(AppiumServiceBuilder.java:407)
	at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:505)
	at AliceTestingEndevours.AppiumCourse.NewAppiumBasics.main(NewAppiumBasics.java:16)

Was following this course.

Whilst I keep looking , Can anyone suggest other things which might work?

Thanks