Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

Aspire Community Toolkit Node.js hosting extensions

Feedback

In this article

Includes:Hosting integration included Hosting integration only —Client integration not included Client integration not included

Note

This integration is part of theAspire Community Toolkit andisn't officially supported by the Aspire team.

In this article, you learn about the Aspire Community Toolkit Node.js hosting extensions package which provides extra functionality to the AspireNodeJS hosting package. The extensions package brings the following features:

  • RunningVite applications
  • Running Node.js applications usingYarn andpnpm
  • Ensuring that the packages are installed before running the application (using the specified package manager)

Hosting integration

To get started with the Aspire Community Toolkit Node.js hosting extensions, install the📦 CommunityToolkit.Aspire.Hosting.NodeJS.Extensions NuGet package in the AppHost project.

dotnet add package CommunityToolkit.Aspire.Hosting.NodeJS.Extensions

For more information, seedotnet add package orManage package dependencies in .NET applications.

Example usage

The following sections detail various usages, from running Vite applications to using specific package managers.

Run specific package managers

This integration extension adds support for running Node.js applications using Yarn or pnpm as the package manager.

var builder = DistributedApplication.CreateBuilder(args);builder.AddYarnApp("yarn-demo")       .WithExternalHttpEndpoints();

Run Vite apps

This integration extension adds support for running the development server for Vite applications. By default, it uses thenpm package manager to launch, but this can be overridden with thepackageManager argument.

var builder = DistributedApplication.CreateBuilder(args);builder.AddViteApp("vite-demo")       .WithExternalHttpEndpoints();builder.AddViteApp("yarn-demo", packageManager: "yarn")       .WithExternalHttpEndpoints();builder.AddViteApp("pnpm-demo", packageManager: "pnpm")       .WithExternalHttpEndpoints();builder.Build().Run();

Install packages

When using theWithNpmPackageInstallation,WithYarnPackageInstallation orWithPnpmPackageInstallation methods, the package manager is used to install the packages before starting the application. These methods are useful to ensure that packages are installed before the application starts, similar to how a .NET application would restore NuGet packages before running.

See also

Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, seeour contributor guide.

Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?