diff --git a/packages/oauth/test/helpers.ts b/packages/oauth/test/helpers.ts index f877bb642..f0e3311cf 100644 --- a/packages/oauth/test/helpers.ts +++ b/packages/oauth/test/helpers.ts @@ -1,12 +1,12 @@ import { spawn, type ChildProcessByStdio } from 'node:child_process'; import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises'; +import { createRequire } from 'node:module'; import { tmpdir } from 'node:os'; import { dirname, join } from 'node:path'; import type { Readable } from 'node:stream'; -import { fileURLToPath } from 'node:url'; const tsxCli = join( - dirname(fileURLToPath(import.meta.resolve('tsx/package.json'))), + dirname(createRequire(import.meta.url).resolve('tsx/package.json')), 'dist', 'cli.mjs', ); diff --git a/packages/telemetry/test/telemetry.test.ts b/packages/telemetry/test/telemetry.test.ts index e143ad9b8..8e6551b4d 100644 --- a/packages/telemetry/test/telemetry.test.ts +++ b/packages/telemetry/test/telemetry.test.ts @@ -1,9 +1,10 @@ import { spawn } from 'node:child_process'; import { mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'; import { mkdtemp } from 'node:fs/promises'; +import { createRequire } from 'node:module'; import { tmpdir } from 'node:os'; import { dirname, join } from 'node:path'; -import { fileURLToPath, pathToFileURL } from 'node:url'; +import { pathToFileURL } from 'node:url'; import { afterEach, describe, expect, it, vi } from 'vitest'; @@ -852,7 +853,7 @@ async function runTelemetryCrashScript(body: string): Promise { const scriptPath = join(dir, 'crash-worker.ts'); const testDir = import.meta.dirname; const tsxCli = join( - dirname(fileURLToPath(import.meta.resolve('tsx/package.json'))), + dirname(createRequire(import.meta.url).resolve('tsx/package.json')), 'dist/cli.mjs', ); const crashModuleUrl = pathToFileURL(join(testDir, '../src/crash.ts')).href;