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);
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.