This error started to occur from node version >= 16.17.0 due to some changes in the Experimental ESM Loader Hooks API.
Solution to resolve this error:
- Downgrade the node version to 16.16.0 and you will not see this error.
- Since you were using appium v2.x with wdio javascript, install dependency
ts-node
by running the following command:
npm install ts-node --save-dev
Reason
Appium v1.x
does not support TypeScript natively, and therefore it does not use the tsconfig.json
file. Appium v1.x is based on Node.js, which supports JavaScript natively but does not include TypeScript support out of the box.
Appium v2.x
will have better TypeScript support out of the box. The new version of Appium is based on the WebDriver protocol and will be implemented in TypeScript. This means that developers will be able to write tests in TypeScript without having to set up a separate TypeScript compiler or configure TypeScript manually. Using TypeScript
and tsconfig
in Appium 2.0
brings several benefits, such as better code maintainability and error checking, improved code readability, and better tooling support.
Important Note
This error will not occur if you use Appium v1.x
with latest node version (>16.16.0) in the wdio
.