From 74cf1af86eae516dfceb0a19962dc4e2e698bab0 Mon Sep 17 00:00:00 2001 From: Bryce Russell Date: Wed, 6 Mar 2024 09:37:08 -0600 Subject: [PATCH] Fix cli package resolution for `@astrojs/db` (#10338) --- packages/astro/src/cli/install-package.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/cli/install-package.ts b/packages/astro/src/cli/install-package.ts index f4e43f968f7b..23699cf34873 100644 --- a/packages/astro/src/cli/install-package.ts +++ b/packages/astro/src/cli/install-package.ts @@ -1,5 +1,6 @@ import { createRequire } from 'node:module'; import { sep } from 'node:path'; +import { pathToFileURL } from 'node:url'; import boxen from 'boxen'; import { execa } from 'execa'; import { bold, cyan, dim, magenta } from 'kleur/colors'; @@ -28,8 +29,8 @@ export async function getPackage( const packageJsonLoc = require.resolve(packageName + '/package.json', { paths: [options.cwd ?? process.cwd()], }); - const packageLoc = packageJsonLoc.replace(`package.json`, 'dist/index.js'); - const packageImport = await import(packageLoc); + const packageLoc = pathToFileURL(packageJsonLoc.replace(`package.json`, 'dist/index.js')); + const packageImport = await import(packageLoc.toString()); return packageImport as T; } await tryResolve(packageName, options.cwd ?? process.cwd());