I wrote this method to start appium server …
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecuteResultHandler;
import org.apache.commons.exec.DefaultExecutor;
import java.io.IOException;
public class AppiumServerUtils {
public static void startServer() {
CommandLine cmd = new CommandLine("\"C:\\Program Files\\nodejs\\node.exe\"");
cmd.addArgument("\"C:\\Users\\HP\\AppData\\Roaming\\npm\\node_modules\\appium\\build\\lib\\main.js\"");
cmd.addArgument("--address");
cmd.addArgument("127.0.0.1");
cmd.addArgument("--port");
cmd.addArgument("4723");
DefaultExecuteResultHandler handler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
try {
executor.execute(cmd, handler);
Thread.sleep(10000);
}catch (IOException | InterruptedException e) {
e.printStackTrace();
}
I have latest node and npm versions installed and set env varioables – C:\Users\HP\AppData\Roaming\npm , C:\Program Files\nodejs
when i run this method, i got this error - “[Appium] Command ‘npm.cmd --version’ exited with code 1”
Could you please give me a solution?