# JavaScriptAppResource

- Module: [Aspire.Hosting.JavaScript](/reference/api/typescript/aspire.hosting.javascript.md)
- Version: `13.4.0`
- Kind: `handle`
- Source: [GitHub](https://github.com/microsoft/aspire)

A resource that represents a JavaScript application.

## Definition

```typescript
interface JavaScriptAppResource
  extends IComputeResource,
    IResource,
    IResourceWithArgs,
    IResourceWithEndpoints,
    IResourceWithEnvironment,
    IResourceWithProbes,
    IResourceWithWaitSupport,
    IResourceWithContainerFiles,
    IResourceWithServiceDiscovery {
  publishAsNodeServer(
      entryPoint: string,
      outputPath?: string): JavaScriptAppResource;
  publishAsPackageScript(
      scriptName?: string,
      runScriptArguments?: string): JavaScriptAppResource;
  publishAsStaticWebsite(
      apiPath?: string,
      apiTarget?: IResourceWithServiceDiscovery,
      outputPath?: string,
      stripPrefix?: boolean,
      targetEndpointName?: string): JavaScriptAppResource;
  withBrowserDebugger(browser?: string): JavaScriptAppResource;
  withBuildScript(
      scriptName: string,
      args?: string[]): JavaScriptAppResource;
  withBun(
      install?: boolean,
      installArgs?: string[]): JavaScriptAppResource;
  withNpm(
      install?: boolean,
      installCommand?: string,
      installArgs?: string[]): JavaScriptAppResource;
  withPnpm(
      install?: boolean,
      installArgs?: string[]): JavaScriptAppResource;
  withRunScript(
      scriptName: string,
      args?: string[]): JavaScriptAppResource;
  withYarn(
      install?: boolean,
      installArgs?: string[]): JavaScriptAppResource;
}
```

## Methods

- [publishAsNodeServer](/reference/api/typescript/aspire.hosting.javascript/javascriptappresource/publishasnodeserver.md) -- `method` -- Configures the JavaScript application to publish as a standalone Node.js server that runs a built artifact directly.
    ```typescript
  publishAsNodeServer(entryPoint: string, outputPath?: string): JavaScriptAppResource
  ```
- [publishAsPackageScript](/reference/api/typescript/aspire.hosting.javascript/javascriptappresource/publishaspackagescript.md) -- `method` -- Configures the JavaScript application to publish as a Node.js server that uses a `package.json` script at runtime.
    ```typescript
  publishAsPackageScript(scriptName?: string, runScriptArguments?: string): JavaScriptAppResource
  ```
- [publishAsStaticWebsite](/reference/api/typescript/aspire.hosting.javascript/javascriptappresource/publishasstaticwebsite.md) -- `method` -- Publishes the JavaScript application as a standalone static website using YARP.
    ```typescript
  publishAsStaticWebsite(apiPath?: string, apiTarget?: IResourceWithServiceDiscovery, outputPath?: string, stripPrefix?: boolean, targetEndpointName?: string): JavaScriptAppResource
  ```
- [withBrowserDebugger](/reference/api/typescript/aspire.hosting.javascript/javascriptappresource/withbrowserdebugger.md) -- `method` -- 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.
    ```typescript
  withBrowserDebugger(browser?: string): JavaScriptAppResource
  ```
- [withBuildScript](/reference/api/typescript/aspire.hosting.javascript/javascriptappresource/withbuildscript.md) -- `method` -- Adds a build script annotation to the resource builder using the specified command-line arguments.
    ```typescript
  withBuildScript(scriptName: string, args?: string[]): JavaScriptAppResource
  ```
- [withBun](/reference/api/typescript/aspire.hosting.javascript/javascriptappresource/withbun.md) -- `method` -- Configures the JavaScript resource to use Bun as the package manager and optionally installs packages before the application starts.
    ```typescript
  withBun(install?: boolean, installArgs?: string[]): JavaScriptAppResource
  ```
- [withNpm](/reference/api/typescript/aspire.hosting.javascript/javascriptappresource/withnpm.md) -- `method` -- Configures the Node.js resource to use npm as the package manager and optionally installs packages before the application starts.
    ```typescript
  withNpm(install?: boolean, installCommand?: string, installArgs?: string[]): JavaScriptAppResource
  ```
- [withPnpm](/reference/api/typescript/aspire.hosting.javascript/javascriptappresource/withpnpm.md) -- `method` -- Configures the Node.js resource to use pnpm as the package manager and optionally installs packages before the application starts.
    ```typescript
  withPnpm(install?: boolean, installArgs?: string[]): JavaScriptAppResource
  ```
- [withRunScript](/reference/api/typescript/aspire.hosting.javascript/javascriptappresource/withrunscript.md) -- `method` -- Adds a run script annotation to the specified JavaScript application resource builder, specifying the script to execute and its arguments during run mode.
    ```typescript
  withRunScript(scriptName: string, args?: string[]): JavaScriptAppResource
  ```
- [withYarn](/reference/api/typescript/aspire.hosting.javascript/javascriptappresource/withyarn.md) -- `method` -- Configures the Node.js resource to use yarn as the package manager and optionally installs packages before the application starts.
    ```typescript
  withYarn(install?: boolean, installArgs?: string[]): JavaScriptAppResource
  ```
