LSP tool: uv_spawn cannot find typescript-language-server despite being in PATH (Windows)
Description
The LSP tool fails with ENOENT: no such file or directory, uv_spawn 'typescript-language-server' even though the binary is globally installed and available in PATH.
Environment
- OS: Windows 11 Pro 10.0.26100
- Shell: bash (Git Bash)
- Node manager: nvm via scoop
- typescript-language-server: 5.2.0 (installed globally via npm + locally as devDep)
- Plugin:
typescript-lsp@claude-plugins-officialv1.0.0 enabled
Steps to Reproduce
- Install
typescript-language-serverglobally:npm install -g typescript-language-server typescript - Verify it's in PATH:
which typescript-language-server→/c/Users/<user>/scoop/apps/nvm/current/nodejs/nodejs/typescript-language-server - Enable
typescript-lsp@claude-plugins-officialplugin - Use the LSP tool:
LSP({ operation: "documentSymbol", filePath: "libs/ui/src/lib/button/button.ts", line: 1, character: 1 })
Expected Behavior
LSP tool finds and spawns typescript-language-server using the same PATH available to Bash tool.
Actual Behavior
Error performing documentSymbol: ENOENT: no such file or directory, uv_spawn 'typescript-language-server'
Analysis
which typescript-language-serverworks in Bash tool → binary is in PATHecho $PATHshows/c/Users/<user>/scoop/apps/nvm/current/nodejs/nodejsis present- The binary also exists at
node_modules/.bin/typescript-language-server(installed as devDep) uv_spawnused by the LSP tool does not appear to inherit the same PATH that the Bash tool uses- Restarting the Claude Code session does not resolve the issue
Workaround
None found. The LSP tool appears to use a different PATH resolution mechanism (uv_spawn) than the Bash tool.
Confirming this bug and adding deeper root cause + a partial workaround.
Root cause: libuv only searches .exe, not .cmd
The PATH inheritance theory is incomplete. The real cause is in libuv's process spawn on Windows:
uv_spawn calls SearchPathW with no extension fallback. According to libuv's search_path_join_test it appends only .exe when the command name has no dot. .cmd and .bat are never tried, regardless of PATHEXT.
This is why:
which typescript-language-serverworks in Bash → it shells out via cmd.exe which respects PATHEXTGet-Command typescript-language-serverworks in PowerShell → sameuv_spawn 'typescript-language-server'fails → libuv only looks fortypescript-language-server.exe
npm and pnpm globally install Node CLIs as .cmd shims (no .exe), so libuv can never find them by bare name.
Reproduction (Windows 11, Node v25.8.1, Claude Code 2.1.142)
where typescript-language-server
> C:\Users\<u>\AppData\Roaming\npm\typescript-language-server
> C:\Users\<u>\AppData\Roaming\npm\typescript-language-server.cmd
# Direct exec works:
& 'C:\Users\<u>\AppData\Roaming\npm\typescript-language-server.cmd' --version
> 5.2.0
# LSP tool fails:
ENOENT: no such file or directory, uv_spawn 'typescript-language-server'
Partial workaround — pyright only
pyright-langserver can be installed as a real .exe via pipx:
pipx install pyright
# Creates C:\Users\<u>\.local\bin\pyright-langserver.exe (PE binary)
After this, the pyright-lsp@claude-plugins-official plugin works correctly. Verified that LSP({ operation: "documentSymbol", filePath: <python file> }) returns symbols and diagnostics flow.
No workaround for typescript-language-server
typescript-language-server has no native Windows .exe — only npm-style shims. Users would need to bundle it themselves (@yao-pkg/pkg or similar) to produce a PE binary, which is fragile, version-locked, and burns ~30 MB per binary.
Suggested fixes (plugin side)
- Pass
shell: trueto spawn on Windows — simplest fix, lets cmd.exe resolve PATHEXT. - Implement explicit PATHEXT lookup before calling libuv spawn — same approach
cross-spawnuses. - Allow the plugin manifest to declare the command explicitly (e.g.
pwsh -Command typescript-language-server) so users can opt into a working invocation.
Option 1 is one line of code and fixes pyright (pip-installed), typescript-language-server, and every other LSP that gets installed via npm/pnpm/yarn on Windows.
cc related closed issues: #54650, #51191, #41839 — same root cause, all closed without a fix shipped.
- Pass
shell: trueto spawn on Windows — simplest fix, lets cmd.exe resolve PATHEXT.
can u teach me the details,thks
Still reproducing on Claude Code v2.1.150 (Windows 11) — plus a working workaround
Confirming this is still broken on CC v2.1.150, which is after the fix claimed for #17312 ("fixed in 2.1.132"). That fix does not cover the npm-global-bin spawn path.
Environment
- Windows 11 Pro 10.0.26200 · Node v22.22.2 · npm 11.14.1
- typescript-language-server 5.2.0 + typescript 5.9.3 (global)
- Plugin:
typescript-lsp@claude-plugins-officialv1.0.0 - Symptom: LSP tool call (documentSymbol/hover/…) hangs ~5 min, then
internal error.
Spawn-level repro (minimal LSP client launching the server the way the plugin config does, against npm bin dir …\AppData\Roaming\npm\):
How typescript-language-server is launched |
Result |
|---|---|
bare name, no shell (= the plugin's command) |
resolves to the POSIX sh shim → stderr Cannot open shim file for read. Could not read shim file. → server exits code 1 → handshake never completes → hang |
…\typescript-language-server.cmd, no shell |
Node throws spawn EINVAL (Node ≥18 blocks spawning .cmd/.bat without shell:true, CVE-2024-27980) |
.cmd with shell:true |
✅ works |
node …\lib\cli.mjs --stdio, no shell |
✅ works |
Consistent with @esmelyvaldivieso99-code's libuv analysis (uv_spawn only appends .exe, never .cmd/PATHEXT). The npm bin dir here has only the extensionless sh shim + .cmd + .ps1 — no .exe — so uv_spawn can't resolve it, and even resolving the .cmd would still need shell:true.
Working workaround (this issue says "None found"): override the plugin's LSP command to run the JS entrypoint directly via node — no shell needed, dodges both the shim and the .cmd EINVAL. Edit the lspServers.typescript block in the marketplace manifest (~/.claude/plugins/marketplaces/<marketplace>/.claude-plugin/marketplace.json):
"typescript": {
"command": "node",
"args": [
"C:\\Users\\<you>\\AppData\\Roaming\\npm\\node_modules\\typescript-language-server\\lib\\cli.mjs",
"--stdio"
]
}
then /reload-plugins. After this, documentSymbol/hover/goToDefinition/findReferences all work. Caveat: the manifest is regenerated on marketplace update, so this needs re-applying — and there's no settings.json override for plugin lspServers.
Proper fix remains on Claude Code's side: shell:true on Windows (or PATHEXT/cross-spawn resolution) before uv_spawn.
https://github.com/anthropics/claude-code/issues/46702#issuecomment-4314953479
change the marketplace.json file , for jdtls
Working workaround
Edit ~/.claude/plugins/marketplaces/claude-plugins-official/.claude-plugin/marketplace.json and append .cmd:
"lspServers": {
"jdtls": {
- "command": "jdtls",
+ "command": "jdtls.cmd",
"args": ["--stdio"],
...
}
}
Durable Windows workaround — local plugin + .lsp.json (updated with a correction)
Updating my earlier note after testing this end-to-end on Windows 11 (Claude Code 2.1.150, Node v22.22). There are two parts: the launch command, and where you put it so a fresh session actually loads it — the second part is what bit me.
1. Launch command
Spawn node against the language server's JS entry, so uv_spawn resolves a real node.exe and you dodge both the extensionless sh shim and the .cmd EINVAL:
"command": "node",
"args": ["C:/Users/<you>/AppData/Roaming/npm/node_modules/typescript-language-server/lib/cli.mjs", "--stdio"]
node cli.mjs --stdio passes a standalone LSP initialize handshake, so the server itself is healthy.
2. Where to declare it — correction to my previous comment
I previously suggested putting lspServers in a user-owned local directory marketplace's marketplace.json (to avoid the official manifest being re-synced on update). That part is right, but the lspServers-in-marketplace.json bit is not enough: a freshly-started session does not register lspServers from a local directory marketplace's marketplace.json. It only hot-loads when you run /plugin install in that live session (in-memory, that process only). A brand-new process gives:
No LSP server available for file type: .ts
I confirmed this with a fresh headless claude -p LSP call: same-session-after-/plugin install works, but any new process fails — startup builds its LSP table from the remote catalog cache, which doesn't include local marketplaces.
What a fresh session does read is a .lsp.json at the plugin root (auto-discovered, like .mcp.json). Put the server map there and new sessions pick it up. Verified: a brand-new claude process then returns documentSymbol/hover for .ts.
Layout
~/.claude/local-marketplaces/win-lsp-fix/
├── .claude-plugin/
│ └── marketplace.json # catalog entry, "source": "./plugins/typescript-lsp-win"
└── plugins/
└── typescript-lsp-win/
├── .claude-plugin/
│ └── plugin.json # { "name": "typescript-lsp-win", "version": "1.0.0" }
└── .lsp.json # ← the part fresh sessions actually read
plugins/typescript-lsp-win/.lsp.json (the server map directly — no lspServers wrapper):
{
"typescript": {
"command": "node",
"args": [
"C:/Users/<you>/AppData/Roaming/npm/node_modules/typescript-language-server/lib/cli.mjs",
"--stdio"
],
"extensionToLanguage": {
".ts": "typescript", ".tsx": "typescriptreact",
".js": "javascript", ".jsx": "javascriptreact",
".mts": "typescript", ".cts": "typescript",
".mjs": "javascript", ".cjs": "javascript"
}
}
}
Wire up once
/plugin marketplace add C:\Users\<you>\.claude\local-marketplaces\win-lsp-fix
/plugin install typescript-lsp-win@win-lsp-fix
/plugin disable typescript-lsp@claude-plugins-official
Then open a new window. Don't rely on /reload-plugins — it reports 1 plugin LSP server registered but does not wire it into the running session's LSP tool; only a freshly-started process picks up the .lsp.json.
Because this lives in a local directory marketplace, it isn't re-synced on Claude Code updates. Still a workaround — the proper fix (shell: true, or PATHEXT / cross-spawn-style resolution before uv_spawn) remains on the Claude Code side.
Still reproduces on v2.1.168 / Windows 11. /doctor reports ENOENT: ... uv_spawn 'typescript-language-server' even though the server is installed and on PATH.
Confirmed the root cause with a minimal repro (Node 24):
spawn, shell:false |
result |
|---|---|
typescript-language-server |
ENOENT |
typescript-language-server.cmd |
EINVAL |
node lib/cli.mjs |
✅ works |
any of the above with shell:true |
✅ works |
So it's the known interaction: Claude Code spawns the bare command without shell:true; npm on Windows installs only a .cmd shim (no .exe); Node ≥18 (CVE-2024-27980) refuses to run .cmd/.bat without a shell; and libuv's no-shell uv_spawn resolves only .exe via SearchPathW. The v2.1.132 change fixed the empty-results half but not this spawn path for npm-global marketplace plugins.
Proper fix: on win32, spawn LSP servers with shell:true (or via cross-spawn, or resolve against PATHEXT before spawning).
Robust user-side workaround (survives plugin + npm updates, no config edits): drop a real typescript-language-server.exe into the npm global dir. A no-shell spawn resolves .exe before .cmd (PATHEXT order), so the bare-name spawn finds it; the exe just execs node …/cli.mjs.
⚠️ One non-obvious catch: the launcher must hand the parent's stdio to node via inherited handles (CreateProcess + STARTF_USESTDHANDLES). A launcher that creates its own pipes and byte-pumps silently fails — Node/libuv won't process LSP JSON-RPC over .NET anonymous pipes (stdin bytes arrive, server never replies). Verified with an initialize round-trip: the inherited-handle exe returns the identical capabilities payload as node cli.mjs --stdio.
launcher.cs — compiles with the bundled .NET csc, zero deps
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
// Real .exe so a no-shell spawn can resolve it (PATHEXT tries .EXE before .CMD).
// Execs `node <cli.mjs> <args>`, passing the parent's stdio through via inherited
// handles (NOT new pipes — libuv won't process LSP traffic over .NET anon pipes).
class Launcher
{
const int STD_INPUT_HANDLE = -10, STD_OUTPUT_HANDLE = -11, STD_ERROR_HANDLE = -12;
const uint STARTF_USESTDHANDLES = 0x00000100, DUPLICATE_SAME_ACCESS = 0x00000002, INFINITE = 0xFFFFFFFF;
[StructLayout(LayoutKind.Sequential)]
struct STARTUPINFO {
public int cb; public IntPtr lpReserved, lpDesktop, lpTitle;
public int dwX, dwY, dwXSize, dwYSize, dwXCountChars, dwYCountChars, dwFillAttribute;
public uint dwFlags; public short wShowWindow, cbReserved2;
public IntPtr lpReserved2, hStdInput, hStdOutput, hStdError;
}
[StructLayout(LayoutKind.Sequential)]
struct PROCESS_INFORMATION { public IntPtr hProcess, hThread; public int dwProcessId, dwThreadId; }
[DllImport("kernel32.dll", SetLastError = true)] static extern IntPtr GetStdHandle(int n);
[DllImport("kernel32.dll")] static extern IntPtr GetCurrentProcess();
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool DuplicateHandle(IntPtr sp, IntPtr s, IntPtr tp, out IntPtr t, uint a, bool inh, uint o);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
static extern bool CreateProcess(string app, string cmd, IntPtr pa, IntPtr ta, bool inh, uint f, IntPtr env, string cwd, ref STARTUPINFO si, out PROCESS_INFORMATION pi);
[DllImport("kernel32.dll", SetLastError = true)] static extern uint WaitForSingleObject(IntPtr h, uint ms);
[DllImport("kernel32.dll", SetLastError = true)] static extern bool GetExitCodeProcess(IntPtr h, out uint c);
[DllImport("kernel32.dll", SetLastError = true)] static extern bool CloseHandle(IntPtr h);
static string Quote(string s) {
if (s.Length > 0 && s.IndexOfAny(new[] { ' ', '\t', '"' }) < 0) return s;
var b = new StringBuilder(); b.Append('"'); int sl = 0;
foreach (char c in s) {
if (c == '\\') sl++;
else if (c == '"') { b.Append('\\', sl * 2 + 1); sl = 0; b.Append('"'); }
else { b.Append('\\', sl); sl = 0; b.Append(c); }
}
b.Append('\\', sl * 2); b.Append('"'); return b.ToString();
}
static IntPtr Inheritable(IntPtr h) {
if (h == IntPtr.Zero || h == new IntPtr(-1)) return h;
IntPtr d; return DuplicateHandle(GetCurrentProcess(), h, GetCurrentProcess(), out d, 0, true, DUPLICATE_SAME_ACCESS) ? d : h;
}
static int Main(string[] args) {
string exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string cli = Path.Combine(exeDir, "node_modules", "typescript-language-server", "lib", "cli.mjs");
string nodePath = @"C:\Program Files\nodejs\node.exe";
bool haveNode = File.Exists(nodePath);
string app = haveNode ? nodePath : null; // null -> CreateProcess PATH-searches
string node0 = haveNode ? nodePath : "node.exe";
var cmd = new StringBuilder();
cmd.Append(Quote(node0)).Append(' ').Append(Quote(cli));
foreach (var a in args) { cmd.Append(' '); cmd.Append(Quote(a)); }
var si = new STARTUPINFO();
si.cb = Marshal.SizeOf(typeof(STARTUPINFO));
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = Inheritable(GetStdHandle(STD_INPUT_HANDLE));
si.hStdOutput = Inheritable(GetStdHandle(STD_OUTPUT_HANDLE));
si.hStdError = Inheritable(GetStdHandle(STD_ERROR_HANDLE));
PROCESS_INFORMATION pi;
if (!CreateProcess(app, cmd.ToString(), IntPtr.Zero, IntPtr.Zero, true, 0, IntPtr.Zero, null, ref si, out pi)) {
Console.Error.WriteLine("launcher: CreateProcess failed, err=" + Marshal.GetLastWin32Error());
return 1;
}
CloseHandle(si.hStdInput); CloseHandle(si.hStdOutput); CloseHandle(si.hStdError); CloseHandle(pi.hThread);
WaitForSingleObject(pi.hProcess, INFINITE);
uint code; GetExitCodeProcess(pi.hProcess, out code); CloseHandle(pi.hProcess);
return unchecked((int)code);
}
}
Build & install:
csc /target:exe /out:"%AppData%\npm\typescript-language-server.exe" launcher.cs
Then restart Claude Code. Same pattern fixes other npm-shim LSP plugins (e.g. intelephense); pyright is hit-or-miss depending on the shim its installer ships.
Still broken in v2.1.173 — plus a second, undocumented bug that breaks the absolute-path workaround for default Node installs
Confirming the .cmd spawn failure still reproduces on v2.1.173 (Windows 10 Pro, VS Code extension). The node + cli.mjs workaround from this thread does work — but there's a trap nobody seems to have documented:
The marketplace manifest schema silently rejects command paths containing spaces. If you use the absolute path to a default Node install:
"command": "C:/Program Files/nodejs/node.exe"
the plugin entry fails validation at startup and gets stubbed. The only trace is a debug-level line in the extension host log:
[WARN] Stubbing unparseable marketplace plugin entry (typescript-lsp): lspServers: Invalid input
The LSP tool then reports No LSP server available for file type: .ts — indistinguishable from a missing plugin. Since C:\Program Files\nodejs\ is where the official Node installer puts node.exe, anyone trying the absolute-path variant of the workaround hits this and concludes the workaround doesn't work.
What works in v2.1.173 (verified for both typescript-lsp and php-lsp/intelephense):
"command": "node"(bare, as posted above), or- copy
node.exeto a space-free path and use that absolute path — more robust if the harness process PATH is unreliable:
"typescript": {
"command": "C:/Users/<you>/.local/bin/node.exe",
"args": ["C:/Users/<you>/AppData/Roaming/npm/node_modules/typescript-language-server/lib/cli.mjs", "--stdio"]
}
After editing: a full VS Code restart is required — the LSP catalog is built once at startup; window reload is not enough.
So there are really two independent Windows bugs here: (1) uv_spawn can't resolve npm .cmd shims (this issue), and (2) the lspServers schema rejecting commands with spaces, which masks the known workaround. Worth fixing both — (2) looks like a one-line validation fix.