英文:
Error: "ts-node/esm/transpile-only 'resolve'" did not call the next hook in its chain and did
问题
错误信息:在使用 npx wdio 命令运行测试时遇到此错误。
如何解决此问题。
错误: "ts-node/esm/transpile-only 'resolve'" 没有调用其链中的下一个钩子,也没有明确地发出短路信号。如果这是有意的,请在钩子的返回中包括 shortCircuit: true
。
英文:
Getting this error when run the test using npx wdio command.
How to resolve this issue.
Error: "ts-node/esm/transpile-only 'resolve'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include shortCircuit: true
in the hook's return.
答案1
得分: 6
最简单的方法是将TypeScript和ts-node添加到项目中。
npm i -D typescript ts-node
然后运行以下命令:
npx wdio
我选择不在WebdriverIO项目中使用编译器,但在几周后开始出现此错误。我只是添加了上述库,而不是试图追踪可能搞砸的配置,以消除错误消息。
英文:
The simplest way to get this running is to add typescript and ts-node to the project.
npm i -D typescript ts-node
Then npx wdio
I opted not to use the compiler in a WebdriverIO project but then started getting this error after a few weeks. I just added the libraries above rather than try to chase down the config i likely messed up, in order to eliminate the error message.
答案2
得分: 1
这个错误开始出现在 Node 版本 >= 16.17.0,因为实验性 ESM Loader Hooks API 的一些更改。
解决这个错误的方法:
- 降级 Node 版本到 16.16.0,就不会看到这个错误了。
- 由于您正在使用 appium v2.x 与 wdio javascript,请运行以下命令安装依赖项
ts-node
:
npm install ts-node --save-dev
原因
Appium v1.x
不原生支持 TypeScript,因此它不使用 tsconfig.json
文件。 Appium v1.x 基于 Node.js,原生支持 JavaScript,但不包含 TypeScript 支持。
Appium v2.x
将原生提供更好的 TypeScript 支持。Appium 的新版本基于 WebDriver 协议,并且将以 TypeScript 实现。这意味着开发人员可以在 TypeScript 中编写测试,无需设置单独的 TypeScript 编译器或手动配置 TypeScript。在 Appium 2.0
中使用 TypeScript
和 tsconfig
带来了几个好处,如更好的代码可维护性和错误检查,改进的代码可读性以及更好的工具支持。
重要提示
如果您在 wdio
中使用最新的 Node 版本(>16.16.0),则不会出现此错误,即使使用 Appium v1.x
。
英文:
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
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论