npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

wsl-shadow

v0.1.4

Published

Shows which node, npm or bun an AI agent in WSL runs next to your terminal's, and prints the fix.

Readme

wsl-shadow

ci npm JSR license

wsl-shadow shows which node, npm or bun an AI agent in WSL runs, next to the one your terminal runs, and prints the PATH or symlink change that makes them match.

┌─ your terminal: bash, interactive ───────────────────────┐
│ reads ~/.bashrc, nvm puts its bin dir first on PATH      │
│ $ command -v npm                                         │
│ /home/alex/.nvm/versions/node/v22.23.2/bin/npm           │
└──────────────────────────────────────────────────────────┘
┌─ AI agent: wsl.exe -e sh -c ─────────────────────────────┐
│ reads no startup file, Windows PATH entries remain       │
│ $ command -v npm                                         │
│ /mnt/c/Program Files/nodejs/npm                          │
└──────────────────────────────────────────────────────────┘

The problem

WSL appends the Windows PATH to every process. nvm, fnm and the rest load from ~/.bashrc, and Ubuntu's ~/.bashrc returns immediately when the shell is not interactive. Agents start wsl.exe bash -lc, wsl.exe -e sh -c, or a spawn with no shell. None of those read ~/.bashrc.

Linux npm is missing from that PATH, so /mnt/c/Program Files/nodejs/npm wins. npm -v still prints a version. npm config get prefix points at C:\Users\..., and node is often not found at all, because WSL will not run node.exe under the name node.

Install

Run it inside WSL. Prefer the Linux binary or node dist/cli.js: bunx / npx inside WSL can resolve to the Windows Bun or npm.

npm:

bun add wsl-shadow
npm i wsl-shadow

JSR:

bunx jsr add @kanchingyg/wsl-shadow
# Release binary (no Node required)
# Download wsl-shadow-linux-x64 or wsl-shadow-linux-arm64 from the GitHub Release,
# chmod +x it, put it on PATH (for example /usr/local/bin/wsl-shadow).

From a clone:

bun install
bun run build        # dist/cli.js, dist/index.js, types, JSON Schema
bun run build:bin    # dist/wsl-shadow-linux-x64 and dist/wsl-shadow-linux-arm64
node dist/cli.js --json

Quick start

Real run on WSL2 Ubuntu with nvm and with Node also installed on Windows. User names and home paths are swapped. The /mnt/c/Program Files/nodejs hit and the C:\ prefix are what the tool printed.

$ wsl-shadow --view=interactive,login,exec

unreachable node
          interactive /home/alex/.nvm/versions/node/v22.23.2/bin/node
          login       (not found)  <- fails
          exec        (not found)  <- fails
shadow    npm
          interactive /home/alex/.nvm/versions/node/v22.23.2/bin/npm
          login       /mnt/c/Program Files/nodejs/npm  <- fails
          exec        /mnt/c/Program Files/nodejs/npm  <- fails
          measured: `npm config get prefix` = C:\Users\alex\AppData\Roaming\npm (login)

A PATH block in ~/.profile cleared login and left exec on the Windows npm. Symlinks in /usr/local/bin cleared exec too.

Use

wsl-shadow                          # report
wsl-shadow --json                   # schemaVersion 1, for agents and CI
wsl-shadow --fix                    # prints proposals, changes nothing, runs nothing
wsl-shadow --apply                  # shows the plan, asks you to type "apply", then does it
wsl-shadow --undo                   # reverts only what --apply recorded
wsl-shadow --preflight              # pass/fail for a harness; stdout is a PATH prefix
wsl-shadow --mcp                    # read MCP configs (Cursor, Claude, Codex, Kilo, VS Code)
wsl-shadow --view=exec              # interactive, login, exec, exec-zsh, here
wsl-shadow --require=node,npm
wsl-shadow --expect-windows=claude  # treat that tool as expected Windows (exit 0)

Exit 0 when every measured tool is fine. Exit 1 on shadow, windows-only, unreachable, drift, an invisible npm global bin, or a bad MCP server under --mcp. Exit 2 when a tool named in --require is missing. cursor and code are expected to be Windows by default.

| Status | Meaning | |---|---| | ok | every measured view resolves to Linux, same version | | shadow | a Linux build exists, and a view gets Windows | | windows-only | a view gets Windows, and no Linux build exists | | unreachable | a Linux build exists, and a view finds nothing | | drift | every view is Linux, but node/npm/bun --version disagree | | missing | nowhere | | unmeasured | that view could not be run; the tool does not guess |

--json matches schemas/report.v1.schema.json (schemaVersion: 1). The published package also exposes it as wsl-shadow/schema.

How it works

| View | How an agent launches it | What that shell reads | |---|---|---| | interactive | your terminal | ~/.bashrc, and ~/.profile if it is a login | | login | wsl.exe bash -lc, MCP "command": "wsl" | ~/.profile, unless ~/.bash_profile or ~/.bash_login exists | | exec | wsl.exe -e sh -c, bash -c, spawn | nothing | | here | whoever is running wsl-shadow | the PATH it inherited |

Drift and npm globals

Two Linux paths are not enough. If your terminal's node is v22 and the exec launch's node is v20, the status is drift and the exit code is 1.

When npm is already Linux, wsl-shadow runs npm config get prefix in that view and checks whether $prefix/bin is on PATH. If a symlink made npm visible but globals still land in an nvm folder that exec does not search, it warns, names the globals exec cannot run, and exits 1. A PATH block cannot fix that (exec reads no startup file). A link in /usr/local/bin can. --fix prints those links and --apply creates them. The warning clears once every global in that folder is reachable, and returns after the next npm i -g until you run --apply again.

MCP configs (--mcp)

Read-only. Walks known config paths on the Linux home and under the Windows profile mount (/mnt/c/Users/...). Each path is marked verified (that client's docs), reported (a published guide), or unverified (guess).

For every server whose command is wsl / wsl.exe, or a bare npx / node / bun, it picks the launch view (login vs exec vs Windows-native), resolves the program, and prints status plus a printed-only fix hint.

What --fix reaches

Each proposal names the views it fixes and the views it leaves broken. A PATH block can only fix the views whose shell reads that file.

| Proposal | login | exec | |---|---|---| | PATH block in the login file bash actually reads | yes | no | | PATH block in ~/.zshenv | yes, on zsh | zsh -c only | | Symlink in /usr/local/bin | yes | yes | | appendWindowsPath=false | yes, for shadow | yes, for shadow |

sh -c, bash -c, wsl.exe -e and spawn read no startup file. A clean login row leaves those on Windows npm. The only fix for exec is a link in a directory it already searches (/usr/local/bin), or a PATH set in that harness's own config.

appendWindowsPath=false is printed last, as text. It drops code, explorer.exe and cmd.exe from PATH by name. It does not fix unreachable: node stays missing, and npm goes from a Windows path to not found. --apply never does it.

A symlink to ~/.nvm/versions/node/v22.x/bin/npm keeps serving v22 after nvm alias default moves on. Point it at ~/.nvm/current/bin/<tool> (NVM_SYMLINK_CURRENT=true, then nvm use default). --fix and --apply use current when it exists, and say so when it does not. Run wsl-shadow again after changing the default Node.

windows-only on claude means Claude Code is installed on Windows and not in WSL. Pass --expect-windows=claude if that is intentional. The tool never installs Claude.

--apply and --undo

--fix is a dry run and stays one. --apply prints the same plan plus the exact steps, asks you to type apply, and only then writes. --yes replaces the typed answer. Without a terminal and without --yes it refuses.

$ wsl-shadow --apply

--apply plan
  link   sudo ln -s '/home/alex/.nvm/versions/node/v22.23.2/bin/corepack' /usr/local/bin/corepack
  state   /home/alex/.local/state/wsl-shadow/applied.json
  backups /home/alex/.local/state/wsl-shadow/backups
  sudo asks for your password at this terminal, for the link commands only. It is never stored.

Type "apply" to continue, anything else cancels: apply

applied:
  done      /usr/local/bin/corepack -> /home/alex/.nvm/versions/node/v22.23.2/bin/corepack

before -> after
  npm      ok, globals not visible to exec (corepack)  ->  ok
  exit code 1 -> 0

It changes two kinds of thing, and nothing else:

| Change | Where | How it is made safe | |---|---|---| | One PATH block between # >>> wsl-shadow >>> and # <<< wsl-shadow <<< | the file bash reads for login (~/.bash_profile, else ~/.bash_login, else ~/.profile), or ~/.zshenv | backup first; the new text is written to a temp file and must pass bash -n (zsh -n) before it replaces the file; mode and ownership of the existing file are kept; a second run replaces the block, never adds one; only export PATH="dirs:$PATH" lines for Linux dirs that exist | | Symlinks | /usr/local/bin | sudo ln -s, never -f; a name that already exists is skipped; targets must exist and be Linux paths |

  • Links come from the tool proposals (node, npm, bun… found in a manager dir) and from the npm prefix: every global in $(npm config get prefix)/bin that exec cannot run gets a link. Run --apply again after npm i -g to link the new ones. It also removes links it made earlier that now dangle (a deleted nvm version). A dangling link it did not make is left alone.
  • sudo runs only for those link commands, through your normal terminal prompt. wsl-shadow never reads, caches or stores the password. It refuses to run as root. The shipped code always calls the real sudo binary. It does not escalate through the Windows host.
  • Before each change, the intent is written to ~/.local/state/wsl-shadow/applied.json and fsynced (pending). After the change lands it is marked done. If the process dies in between, the next --apply or --undo looks at the real files and either records what landed (so undo can reverse it) or drops the pending entry. Backups go under ~/.local/state/wsl-shadow/backups/. If a file edit fails, no sudo runs.
  • After --apply and --undo it re-measures every view and prints before and after.

--undo reads that state file and nothing else. It removes the links it created (only if they still point where it pointed them), and restores each edited file from the first backup. If you edited the file since, it removes only the marked block and keeps your edit. A file it created is deleted only while it is still exactly what it wrote. To revert by hand: delete the block between the markers, and sudo rm the links listed in applied.json.

Library

ESM with types. Importing it runs nothing: no process, no filesystem, no exit, no output.

import { scan, resolveTool, scanMcp, planFixes, preflight } from "wsl-shadow";

const report = scan({ required: ["node"] });        // same data as --json
const npm = resolveTool("npm");                      // one row; any command name works
const fixes = planFixes(report);                     // dry-run proposals, nothing is run
if (report.exitCode !== 0) console.error(npm.status, npm.consequence);

| Export | Returns | |---|---| | scan(opts?) | Report, the --json payload (schemaVersion: 1) | | resolveTool(name, opts?) | one ToolRow | | scanMcp(opts?) | McpReport, read-only | | planFixes(report, opts?) | Fix[], each with fixesViews, leavesBroken, links | | preflight(opts?) | { exitCode, view, pathPrefix, problems, error } | | planApply, runApply, planUndo, runUndo, createApplyDeps | the --apply / --undo engine, for hosts that confirm in their own UI |

Every function takes an optional runner, fs, env, home, distro, shell, mountRoot, wslExe, timeoutMs, so tests can fake the machine. Functions return data and throw nothing for a bad machine. Only the CLI exits. runApply and runUndo write, and are the only exports that do.

--preflight

A fast pass/fail for a harness before it starts work: one lookup in the exec view (what sh -c, wsl.exe -e and spawn get), for node and npm unless you pass --require=a,b. No versions, no probes.

PATH="$(wsl-shadow --preflight):$PATH"     # prefix on stdout, reasons on stderr
wsl-shadow --preflight --json              # { exitCode, view, pathPrefix, problems, error }

| Exit | Meaning | |---|---| | 0 | every tool resolves to a Linux build in exec | | 1 | a Windows build answers or nothing does, but a Linux build exists; stdout is the PATH prefix that reaches it. Also 1 if the view could not run (error is set, stdout empty) | | 2 | a tool has no Linux build anywhere |

The prefix is the directory of each tool's Linux build, using ~/.nvm/current/bin when it exists. Use the absolute path or a /usr/local/bin link to call wsl-shadow itself from exec.

Wiring, by harness. These are the generic patterns. None was run inside that harness yet:

  • Cursor, Kilo (MCP servers via wsl.exe): "command": "wsl.exe", "args": ["-e", "sh", "-c", "PATH=\"$(/usr/local/bin/wsl-shadow --preflight):$PATH\" exec npx -y your-server"].
  • Codex ([mcp_servers.x] in config.toml): the same command and args. For its shell tool, call wsl-shadow --preflight first and stop on a non-zero exit.
  • Claude Code: run wsl-shadow --preflight || exit 1 in whatever script or hook starts the session, and export the printed prefix into its PATH.

For agents

Paste AGENTS-SNIPPET.md into AGENTS.md, or load skill/wsl-shadow/SKILL.md. Both say: run wsl-shadow --json --view=here before trusting node, npm, bun or claude. You may suggest wsl-shadow --apply, but ask the user before running it, and never edit shell rc files or /usr/local/bin yourself.

Limits

  • Not measured: WSL1, Alpine, which launch form each harness uses, arm64 binary on hardware, --apply with a real interactive sudo prompt (the lab run used a stand-in), --preflight inside each harness.
  • Never touched: /etc/wsl.conf, .wslconfig, /etc/profile, /etc/environment, ~/.bashrc, WSLENV, the Windows PATH, System32, anything under /mnt/<drive>/, or anything it did not create. It never runs wsl --shutdown and does not install nvm, Node, Bun or claude.
  • --mcp never edits config files.

Reported elsewhere

  • openai/codex#20810: node missing, npm under /mnt/c/.../fnm/.
  • GitNexus#1220: interactive which is Linux. wsl bash -lc runs the Windows shim.
  • Kilo#8129: the agent shell skips .bashrc and gets Windows npm.
  • pi#1756: spawnSync("npm") and the shell npm disagree. npm root -g returns C:\.
  • agent-girl f184807: the launcher detects Windows Bun and installs a Linux one.

Contributing

bun install
bun run check-versions   # package.json and jsr.json must match
bun run typecheck
bun test
bun run build
bun run build:bin        # Linux binaries (run under WSL or Linux CI)

Contributor scripts under scripts/:

| Script | Purpose | |---|---| | copy-schema.ts | copies schemas/report.v1.schema.json into dist/ during bun run build | | check-versions.ts | asserts package.json / jsr.json versions match (and the git tag in release CI) | | registry-has-version.ts | exit 0/1/2 for “version already on npm or JSR” (release workflow skips publish when 0) | | verify-dist.sh | smoke-tests dist/cli.js and the Linux x64 binary the way a user without Bun would (run inside WSL after build + build:bin) | | scan-mojibake.py | fails if tracked text files contain UTF-8 replacement characters |

# inside WSL, after a local build
bash scripts/verify-dist.sh
python3 scripts/scan-mojibake.py

Pack / JSR dry runs before a release:

npm pack --dry-run
bunx jsr publish --dry-run

License

AGPL-3.0-only. Free and open source. If you ship a modified version, or run a modified version as a network service, you must publish that source under the AGPL. Closed-source or proprietary commercial use needs a separate license from the author (dual licensing). Ask via GitHub.

The name wsl-shadow is not licensed for use by forks or derived products without permission.

Augusto Cerrutti · github.com/kanchingyg