Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d70498c

Browse files
committedJan 11, 2025·
fix: invalid ESM module path on Windows
1 parent f4f0265 commit d70498c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/node/main.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { commit, version, vsRootPath } from "./constants"
99
import { register } from "./routes"
1010
import { VSCodeModule } from "./routes/vscode"
1111
import { isDirectory, open } from "./util"
12+
import * as os from "os"
1213

1314
/**
1415
* Return true if the user passed an extension-related VS Code flag.
@@ -51,7 +52,11 @@ export const runCodeCli = async (args: DefaultedArgs): Promise<void> => {
5152
try {
5253
// See vscode.loadVSCode for more on this jank.
5354
process.env.CODE_SERVER_PARENT_PID = process.pid.toString()
54-
const modPath = path.join(vsRootPath, "out/server-main.js")
55+
let modPath = path.join(vsRootPath, "out/server-main.js")
56+
if (os.platform() === "win32") {
57+
// On Windows, absolute paths of ESM modules must be a valid file URI.
58+
modPath = "file:///" + modPath.replace(/\\/g, "/")
59+
}
5560
const mod = (await eval(`import("${modPath}")`)) as VSCodeModule
5661
const serverModule = await mod.loadCodeWithNls()
5762
await serverModule.spawnCli(await toCodeArgs(args))

0 commit comments

Comments
 (0)
Please sign in to comment.