GitbookIO / GitbookIO/integrations

EINVAL errors when using Node.JS 18.20.4 on Windows 11

Open
#606 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
131
Forks
96
Avg merge
7h 8m
Merged PRs (30d)
31

Description

Due to a security change in Node.js for Windows (CVE-2024-27980) linked here The "gitbook new" action would throw a spawn EINVAL error when attempting to install dependencies.

The fix I had to do, was add shell:true to the installdependencies function as shown here:

function installDependencies(dirPath) {
  return new Promise((resolve6, reject) => {
    const install = (0, import_child_process2.spawn)(/^win/.test(process.platform) ? "npm.cmd" : "npm", ["install"], {
      studio: "inherit",
      shell: true,
      cwd: dirPath
    });
    install.on("close", (code) => {
      if (code !== 0) {
        throw new Error(`npm install exited with code ${code}`);
      }
      resolve6();
    });
  });
}

However, I'm having a similar issue when attempting the "gitbook dev" action, I get a ENOENT issue which seems to be related to the spawn command also.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the installDependencies function and the spawn calls used by the "gitbook new" and "gitbook dev" actions. Reproduce the commands on Windows 11 with Node.js 18.20.4, then trace the EINVAL and ENOENT results. Done means both actions can install dependencies and start without spawn errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.