From 40fb2f99a529f627a0a3b1efca94a2f7dd5d2f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zhong=20Lufan=20=28=E9=92=9F=E8=B7=AF=E5=B8=86=29?= Date: Mon, 29 Apr 2024 02:22:24 +0800 Subject: [PATCH] Fix NodeJS not loading worker on Windows --- src/libarchive-node.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libarchive-node.ts b/src/libarchive-node.ts index 5b5e092..a3a5cb9 100644 --- a/src/libarchive-node.ts +++ b/src/libarchive-node.ts @@ -1,11 +1,12 @@ import { Worker } from "worker_threads"; -import { URL } from "url"; +import { dirname } from "path"; +import { fileURLToPath } from "url"; import * as Comlink from "comlink"; import nodeEndpoint from "comlink/dist/esm/node-adapter"; import { Archive } from "./libarchive"; export * from "./libarchive"; -const __dirname = new URL(".", import.meta.url).pathname; +const __dirname = dirname(fileURLToPath(import.meta.url)); Archive.init({ getWorker: () => new Worker(`${__dirname}/worker-bundle-node.mjs`),