From 24f33155e034b3382b781fd503e2e524b26dfc5a Mon Sep 17 00:00:00 2001 From: enpitsulin Date: Wed, 2 Oct 2024 12:52:10 +0800 Subject: [PATCH] fix: __dirname --- src/utils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 425a1d1..65da10e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,7 +1,8 @@ import { createHash, createHmac } from 'node:crypto' import { readFileSync } from 'node:fs' -import path from 'node:path' +import path, { dirname } from 'node:path' import { Script } from 'node:vm' +import { fileURLToPath } from 'node:url' import { JSDOM } from 'jsdom' import type { FetchContext } from 'ofetch' import { stringifyQuery } from 'ufo' @@ -77,8 +78,8 @@ export function onSignatureRequest(ctx: FetchContext) { } export function createDeviceId() { - // @ts-expect-error ignore - const sdkJsPath = path.resolve(import.meta.dirname, './sm.sdk.js') + const __dirname = fileURLToPath(dirname(import.meta.url)) + const sdkJsPath = path.resolve(__dirname, './sm.sdk.js') return new Promise((resolve) => { const dom = new JSDOM( '',