[π Bug]: Compatibility Problem with wait-port in WDIO 9 Using Node.js 20+
Have you read the Contributing Guidelines on issues?
- [x] I have read the Contributing Guidelines on issues.
WebdriverIO Version
9.12.7
Node.js Version
22.16.0
Mode
Standalone Mode
Which capabilities are you using?
config.capabilities = [
{
'maxInstances': 1,
browserName: 'MicrosoftEdge',
'ms:edgeOptions': {
args: ['--window-size=1920,1080', '--inprivate'],
},
'wdio:edgedriverOptions': {
binary: './msedgedriver.exe',
},
'wdio:enforceWebDriverClassic': true,
What happened?
The @wdio/cli package internally uses the wait-port module to wait for the browser driver (such as EdgeDriver) to start and listen on a specified port before initiating test execution. This ensures that the test runner does not attempt to connect to the driver before it is ready.
In WDIO version 9, the wait-port module is implemented in CommonJS (CJS) format. However, our project is using Node.js version 20+, which strictly enforces ES Module (ESM) rules. Node.js 20+ does not support importing CJS modules using the import statement when the project is configured with "type": "module" in package.json.
Due to this mismatch, WDIO fails to import the wait-port module, leading to the following error:
javascript
CopyEdit Failed to create session
TypeError: require(...) is not a function
As a result, WDIO is unable to wait for the EdgeDriver to initialize and bind to a port, causing test execution to fail during session creation.
Workaround
To overcome this issue, we downgraded the Node.js version to 18.20.3, which supports both CommonJS and ES Modules, providing better backward compatibility.
After switching to Node.js 18, the tests executed successfully, confirming that the issue is related to the incompatibility between the wait-port moduleβs format and the stricter ESM enforcement in Node.js 20+.
What is your expected behavior?
Session to be created
How to reproduce the bug.
Run scripts in edge browser(latest) using node 20+
Relevant log output
na
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Is there an existing issue for this?
- [x] I have searched the existing issues
Run scripts in edge browser(latest) using node 20+
We are running Edge tests in CI using Node 20+ and they pass fine. Can you provide a simple GitHub project reproducing this problem?
Thanks for raising this issue π
Unfortunately we can't help you without a reproducible example in this matter. Please read our contributing guidelines on how to create a reproducible example. If you can't provide a reproducible example we will close this issue in 7 days.
If you have any questions please reach out to us on our Discord channel. We are happy to help you out there.
Hello, I'm getting the same error when trying to run a spec since today that I updated to Webdriverio 9.15.0
Here's the error:
[0-0] 2025-06-12T21:41:38.982Z ERROR @wdio/runner: TypeError: require(...) is not a function
[0-0] at Object.
I'm using node 20.12.1 and chromedriver 137.0.3, could you please look into it?
Previously when I was using Webdriverio 9.12.7, it worked correctly, right now if I want my specs running again I have to use the workaround of downgrading to node 18.
Previously when I was using Webdriverio 9.12.7
Can you try with the latest WebdriverIO version?
@christian-bromann you mean 9.15.0? That's the latest version I got
Is there another WebdriverIO version?
Yes, please try with the latest, also do you have a reproduction case?
Closing due to inactivity. Happy to re-open once we can get a reproduction case.