Appium is throwing error as “TypeError: Web2Driver.remote is not a function”

Hi Team,
Appium is throwing error as “TypeError: Web2Driver.remote is not a function”, for the code below.

What i wanted to do?
i wanted to execute scripts for following combination (WebdriverJS + Appium + mocha ) on android simulator. Need to execute my scripts on simulator’s chrome browser. Wanted to use “webdriver javascript”, because i have plan to integrate with my existing project. Please let me know if any issue in code below or help with new working code.


OS: MacOS Monterey (Chip -Apple)
Node : v16.16.0, v14.16.0 (also tried with this)
“web2driver”: “^3.0.4” (also tried with ^3.0.0)
“mocha”: “^10.2.0”


import Web2Driver from ‘web2driver’;
// or if you want it with Node:
// import Web2Driver from ‘web2driver/node’;

// const Web2Driver = require(‘web2driver’);

describe(‘Appium demo’, function() {

it('First testcase', async function() { 

const serverOpts = {hostname: "localhost", port: 4723};
// we could also specify 'protocol' and 'path', which default to
// 'http' and '/wd/hub' respectively

const capabilities = {browserName: "Safari"}; //...

// const Web2DriverObj = new Web2Driver();
// initialize a session
const driver = await Web2Driver.remote(serverOpts, capabilities);

// do stuff with a session
const el = await driver.findElement('xpath', '//foo');
// ...

// end the session
await driver.quit();