mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-19 06:45:50 +00:00
fix: 尝试修复 nodejs windows 环境的问题
This commit is contained in:
@@ -68,8 +68,15 @@ let nextId = 1
|
|||||||
/**
|
/**
|
||||||
* Default socket path based on PID, placed in a tmpdir subdirectory so it
|
* Default socket path based on PID, placed in a tmpdir subdirectory so it
|
||||||
* survives across config-home changes and avoids polluting ~/.claude.
|
* survives across config-home changes and avoids polluting ~/.claude.
|
||||||
|
*
|
||||||
|
* On Windows, Node.js requires named pipe paths in the `\\.\pipe\` namespace;
|
||||||
|
* file-system paths like `C:\...\Temp\x.sock` cause EACCES. Bun handles both
|
||||||
|
* transparently, but we use the pipe format on Windows for Node.js compat.
|
||||||
*/
|
*/
|
||||||
export function getDefaultUdsSocketPath(): string {
|
export function getDefaultUdsSocketPath(): string {
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
return `\\\\.\\pipe\\claude-code-${process.pid}`
|
||||||
|
}
|
||||||
return join(tmpdir(), 'claude-code-socks', `${process.pid}.sock`)
|
return join(tmpdir(), 'claude-code-socks', `${process.pid}.sock`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,14 +130,18 @@ export async function startUdsMessaging(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure parent directory exists
|
// Ensure parent directory exists (skip on Windows — pipe paths aren't files)
|
||||||
await mkdir(dirname(path), { recursive: true })
|
if (process.platform !== 'win32') {
|
||||||
|
await mkdir(dirname(path), { recursive: true })
|
||||||
|
}
|
||||||
|
|
||||||
// Clean up stale socket file
|
// Clean up stale socket file (skip on Windows — pipe paths aren't files)
|
||||||
try {
|
if (process.platform !== 'win32') {
|
||||||
await unlink(path)
|
try {
|
||||||
} catch {
|
await unlink(path)
|
||||||
// ENOENT is fine
|
} catch {
|
||||||
|
// ENOENT is fine
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
socketPath = path
|
socketPath = path
|
||||||
@@ -220,12 +231,14 @@ export async function stopUdsMessaging(): Promise<void> {
|
|||||||
})
|
})
|
||||||
server = null
|
server = null
|
||||||
|
|
||||||
// Remove socket file
|
// Remove socket file (skip on Windows — pipe paths aren't files)
|
||||||
if (socketPath) {
|
if (socketPath) {
|
||||||
try {
|
if (process.platform !== 'win32') {
|
||||||
await unlink(socketPath)
|
try {
|
||||||
} catch {
|
await unlink(socketPath)
|
||||||
// Already gone
|
} catch {
|
||||||
|
// Already gone
|
||||||
|
}
|
||||||
}
|
}
|
||||||
delete process.env.CLAUDE_CODE_MESSAGING_SOCKET
|
delete process.env.CLAUDE_CODE_MESSAGING_SOCKET
|
||||||
logForDebugging(
|
logForDebugging(
|
||||||
|
|||||||
Reference in New Issue
Block a user