nodejs / nodejs/corepack

Fails on Windows + Git BASH

Open
#324 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.8k
Forks
279
Avg merge
1h 47m
Merged PRs (30d)
2

Description

The path to corepack binaries for package managers fail in an emulated Linux environment on Windows.

Below, you can see that it's using both the Windows physical "C:" drive path as well as the emulated Linux "/c/" path. The actual Windows path is: "C:\Program Files\nodejs\node_modules\corepack\dist\yarn.js" and the emulated Linux path is: "/c/Program\ Files/nodejs/node_modules/corepack/dist/yarn.js".

Git for Windows is a popular choice among developers and the Git BASH shell is often the default terminal for many VS Code developers.

It's not currently possible to use corepack in Git BASH and the error doesn't make it obvious what a developer should do unless they happen to know about the underlying pathing.

$ yarn --version
node:internal/modules/cjs/loader:1080
  throw err;
  ^

Error: Cannot find module 'C:\c\Program Files\nodejs\node_modules\corepack\dist\yarn.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.18.2

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 by reproducing yarn --version in Git Bash on Windows and trace how Corepack constructs the package-manager binary path. Done means the generated path uses a valid Windows or Git Bash form and the command runs without the MODULE_NOT_FOUND error.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, git, nodejs, typescript
Domain
cli, operating-systems, 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.