Skip to content

Commit

Permalink
Fix getPackage resolve path
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Jun 26, 2024
1 parent d9e6190 commit dc95d67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/famous-maps-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes installed packages detection when running `astro check`
4 changes: 3 additions & 1 deletion packages/astro/src/cli/install-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import prompts from 'prompts';
import whichPm from 'which-pm';
import type { Logger } from '../core/logger/core.js';

const require = createRequire(import.meta.url);

type GetPackageOptions = {
skipAsk?: boolean;
optional?: boolean;
Expand All @@ -24,7 +26,7 @@ export async function getPackage<T>(
try {
// Try to resolve with `createRequire` first to prevent ESM caching of the package
// if it errors and fails here
createRequire(options.cwd ?? process.cwd()).resolve(packageName);
require.resolve(packageName, { paths: [options.cwd ?? process.cwd()] });
const packageImport = await import(packageName);
return packageImport as T;
} catch (e) {
Expand Down

0 comments on commit dc95d67

Please sign in to comment.