execa: Error: Premature close

async function run()
{
    const { execa } = await import('execa');
    await execa({
        stdout: {
            file: "out.txt",
        }
    })`npm run tsc`;
}

run();
        "tsc": "rimraf ./dist/ && tsc --p tsconfig.json"

image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23

Most upvoted comments

Node 22 did include a few bug fixes related to streams, so this must have been the problem. Thanks for sharing the solution!

image image Same error

        {
            "name": "run cur ts",
            "type": "node",
            "request": "launch",
            "args": [
                "${relativeFile}"
            ],
            "runtimeArgs": [
                "--nolazy",
                "-r",
                "ts-node/register/transpile-only",
            ],
            "cwd": "${workspaceFolder}",
            "internalConsoleOptions": "openOnSessionStart"
        },

I currently use ts-node and cjs to run typescript code. The code above is esm. I’m afraid I need to configure my project. Wait for me to configure it.