首页 > 解决方案 > 与 @babel/register 模块相关的 Node Bable 错误“ReferenceError: Unknown option: .caller。检查 .../options/ 以获取有关选项的更多信息”

问题描述

我需要帮助将 babel_node 集成到 NodeJS Typescript 项目中。

我从 github 下载了一个 Typescript babel 项目,然后开始删除将所有项目转换为 typescript 的非 typescript 部分。

我还尝试仅使用 Node 和 TypeScript 来学习代码的深层架构。在这个过程中,一些模块没有集成到我创建的新项目中。

我遇到了一个问题,我需要 babel/register(它在代码中使用)所以我安装了 babel。

现在我尝试启动一个示例应用程序“server-websocket.js”并得到以下错误:

npm run server-websocket
<user>@<computer>:~/<path to application>$ npm run server-websocket
Debugger listening on ws://127.0.0.1:34331/1b7e95f8-3c7f-403d-8f7a-f343f2608d1a
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
(node:4400) ExperimentalWarning: The fs.promises API is experimental

> <application name>@1.0.0 server-websocket
> babel-node examples/run-example.js 'examples/example_websocketserver.js'

Debugger listening on ws://127.0.0.1:33567/353c59ca-f3e6-4440-b5eb-f86489c1accc
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Debugger listening on ws://127.0.0.1:44677/e09b698f-2b68-4a47-8f63-e3f529c84407
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
<path to application>/node_modules/@babel/core/lib/config/validation/options.js:113
    throw new ReferenceError(unknownOptErr);
    ^

ReferenceError: Unknown option: .caller. Check out http://babeljs.io/docs/usage/options/ for more information about options.
    at buildUnknownError (<path to application>/node_modules/@babel/core/lib/config/validation/options.js:113:11)
    at Object.keys.forEach.key (<path to application>/node_modules/@babel/core/lib/config/validation/options.js:99:57)
    at Array.forEach (<anonymous>)
    at validate (<path to application>/node_modules/@babel/core/lib/config/validation/options.js:69:21)
    at loadPrivatePartialConfig (<path to application>/node_modules/@babel/core/lib/config/partial.js:38:50)
    at loadFullConfig (<path to application>/node_modules/@babel/core/lib/config/full.js:43:39)
    at loadOptions (<path to application>/node_modules/@babel/core/lib/config/index.js:27:36)
    at OptionManager.init (<path to application>/node_modules/@babel/core/lib/index.js:215:36)
    at compile (<path to application>/node_modules/@babel/register/lib/node.js:57:42)
    at compileHook (<path to application>/node_modules/@babel/register/lib/node.js:107:12)
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...
Waiting for the debugger to disconnect...
<user>@<computer>:~/<path to application>$ 

有人可以指导我如何解决这些错误吗?

感谢您的提前音频

标签: node.jstypescriptbabeljsruntime-erroroptions

解决方案


推荐阅读