0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-04-14 23:51:49 -05:00

fix: support for Deno to install npm packages (#13548)

Co-authored-by: ematipico <602478+ematipico@users.noreply.github.com>
This commit is contained in:
ryu 2025-04-04 19:42:13 +09:00 committed by GitHub
parent 9520a23d9d
commit e588527b4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

View file

@ -0,0 +1,7 @@
---
'astro': patch
---
Support for Deno to install npm pacakges.
Deno requires npm prefix to install packages on npm. For example, to install react, we need to run `deno add npm:react`. But currently the command executed is `deno add react`, which doesn't work. So, we change the package names to have an npm prefix if you are using Deno.

View file

@ -675,7 +675,12 @@ async function tryToInstallIntegrations({
const installCommand = resolveCommand(packageManager?.agent ?? 'npm', 'add', inheritedFlags);
if (!installCommand) return UpdateResult.none;
const installSpecifiers = await convertIntegrationsToInstallSpecifiers(integrations);
const installSpecifiers = await convertIntegrationsToInstallSpecifiers(integrations).then(
(specifiers) =>
installCommand.command === 'deno'
? specifiers.map((specifier) => `npm:${specifier}`) // Deno requires npm prefix to install packages
: specifiers,
);
const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(' ')} ${cyan(installSpecifiers.join(' '))}`;
const message = `\n${boxen(coloredOutput, {

View file

@ -70,6 +70,10 @@ async function installPackage(
const installCommand = resolveCommand(packageManager?.agent ?? 'npm', 'add', []);
if (!installCommand) return false;
if (installCommand.command === 'deno') {
// Deno requires npm prefix to install packages
packageNames = packageNames.map((name) => `npm:${name}`);
}
const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(' ')} ${cyan(packageNames.join(' '))}`;
const message = `\n${boxen(coloredOutput, {
margin: 0.5,