无法让节点或 ts-node/register 继续使用 es2020(flatMap 不是函数)

Cannot get node or ts-node/register to use es2020 anymore (flatMap is not a function)

我无法将 flatmap 与节点或 ts-node 一起使用,尽管以前可以在我的代码中使用。我不确定发生了什么变化,但我收到此错误 'TypeError: [x].flatMap is not a function' flatMap() 应该是一个函数,因为我明确地将 x 设为一个数组(这段代码在没有问题之前就可以正常工作)。

这是我的 tsconfig.json

{
    "compilerOptions": {
      "moduleResolution": "node",
      "target": "es2020",
      "esModuleInterop": true,
      "sourceMap": true,
      "strictNullChecks": true,
      "outDir": "out",
      //"strictBindCallApply": true,
      //"strict": true
    }
}

这是我的 lancher

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/src/main.ts",
            "outFiles": ["${workspaceFolder}/out/**/*.js"],
            "preLaunchTask": "npm: build",
            "runtimeArgs": ["-r", "esm"],
            "stopOnEntry": true,
            "console": "integratedTerminal",
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Mocha Tests",
            "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
            "args": [
                "-u",
                "tdd",
                "--timeout",
                "999999",
                "--colors",
                "--require",
                "esm",
                "--require",
                "ts-node/register",
                "--project",
                "${workspaceFolder}/tsconfig.json",
                "${workspaceFolder}/**/*spec.ts"
            ],
            "console": "integratedTerminal",
            "stopOnEntry": false,
        }
    ]
}

和有问题的平面图调用

(x: discord.Message | discord.Message[] | null): (discord.Message | null)[] => [x].flatMap(
                                // @ts-ignore
                                (t: discord.Message | discord.Message[] | null): (discord.Message | discord.Message[] | null) => t
                            )

另一个不起作用的例子:

const test = [1,3,4,[5,4,2]].flatMap(x => x);

TypeError: [1,3,4,[5,4,2]].flatMap is not a function

ts-node/register 或 ts-node 似乎都不再尊重 "target": "es2020",我不确定到底发生了什么变化。 VScode 确实有 flatMap 的智能感知上下文。任何人都可以向我解释为什么它不再工作了吗?

问题是我在安装程序后节点的版本号发生冲突。我已经停止使用node的snap包,开始使用nvm了。