builderIDistributedApplicationBuilderThe distributed application builder to which the JavaScript application resource will be added.
namestringThe unique name of the JavaScript application resource. Cannot be null or empty.
appDirectorystringThe path to the directory containing the JavaScript application.
runScriptNamestringoptionalThe name of the npm script to run when starting the application. Defaults to "dev". Cannot be null or empty.
Returns
IResourceBuilder<JavaScriptAppResource> A resource builder for the newly added JavaScript application resource.
Remarks
If a Dockerfile does not exist in the application's directory, one will be generated automatically when publishing. The method configures the resource with Node.js defaults and sets up npm integration.
builderIDistributedApplicationBuilderThe Hosting.IDistributedApplicationBuilder to add the resource to.
namestringThe name of the resource.
appDirectorystringThe path to the directory containing the node application.
scriptPathstringThe path to the script relative to the app directory to run.
Returns
IResourceBuilder<NodeAppResource> A reference to the ApplicationModel.IResourceBuilder`1.
Remarks
This method executes a Node script directly using node script.js. If you want to use a package manager you can add one and configure the install and run scripts using the provided extension methods. If the application directory contains a package.json file, npm will be added as the default package manager.
Examples
Add a Node app to the application model using yarn and 'yarn run dev' for running during development:
var builder =DistributedApplication.CreateBuilder(args);
Configures a browser debugger for the JavaScript application resource, enabling browser-based debugging through a child resource that launches when the parent application is ready.
builderIResourceBuilder<T>The resource builder for the JavaScript application.
browserstringoptionalThe browser to use for debugging. Defaults to "msedge". Supported values include "msedge" and "chrome".
Returns
IResourceBuilder<T> A reference to the ApplicationModel.IResourceBuilder`1 for chaining additional configuration.
Exceptions
InvalidOperationException Thrown when the parent resource does not have an HTTP or HTTPS endpoint, or when the IDE extension does not support browser debugging.
Remarks
This method creates a child JavaScript.BrowserDebuggerResource that waits for the parent JavaScript application to start, then launches a browser debug session targeting the parent's HTTP or HTTPS endpoint. The parent resource must have at least one HTTP or HTTPS endpoint configured.
Examples
Add browser debugging to a JavaScript application:
var builder =DistributedApplication.CreateBuilder(args);
installbooloptionalWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installArgsstring[]?optionalAdditional command-line arguments passed to "bun install". When null, defaults are applied based on publish mode and lockfile presence.
Returns
IResourceBuilder<TResource> A reference to the ApplicationModel.IResourceBuilder`1.
Remarks
Bun forwards script arguments without requiring the -- command separator, so this method configures the resource to omit it. When publishing and a bun lockfile ( bun.lock or bun.lockb) is present, --frozen-lockfile is used by default. Publishing to a container requires Bun to be present in the build image. This method configures a Bun build image when one is not already specified. To use a specific Bun version, configure a custom build image (for example, oven/bun:<tag>) using ContainerResourceBuilderExtensions.WithDockerfileBaseImage.
Examples
Run a Vite app using Bun as the package manager:
var builder =DistributedApplication.CreateBuilder(args);
builder.AddViteApp("frontend","./frontend")
.WithBun()
.WithDockerfileBaseImage(buildImage:"oven/bun:latest");// To use a specific Bun image
installbooloptionalWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installCommandstring?optionalThe install command itself passed to npm to install dependencies.
installArgsstring[]?optionalThe command-line arguments passed to npm to install dependencies.
Returns
IResourceBuilder<TResource> A reference to the ApplicationModel.IResourceBuilder`1.
installbooloptionalWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installArgsstring[]?optionalThe command-line arguments passed to "pnpm install".
Returns
IResourceBuilder<TResource> A reference to the ApplicationModel.IResourceBuilder`1.
Adds a run script annotation to the specified JavaScript application resource builder, specifying the script to execute and its arguments during run mode.
installbooloptionalWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
installArgsstring[]?optionalThe command-line arguments passed to "yarn install".
Returns
IResourceBuilder<TResource> A reference to the ApplicationModel.IResourceBuilder`1.