# JavaScriptAppResource.PublishAsPackageScript

- Module: [Aspire.Hosting.JavaScript](/reference/api/go/aspire.hosting.javascript.md)
- Defined on: [JavaScriptAppResource](/reference/api/go/aspire.hosting.javascript/javascriptappresource.md)
- Version: `17.0.0`
- Kind: `method`

Configures the JavaScript application to publish as a server that runs a package manager script at runtime.

## Remarks

Use this method for frameworks where the production server depends on packages resolved at runtime, either
from `node_modules` or from the Deno dependency cache. The resulting container includes the full
application with its production dependencies already installed.
This method is appropriate for frameworks like Nuxt (where `useAsyncData`/`useFetch` requires the
full Nitro environment), Remix (where `react-router-serve` is an npm dependency), and Astro SSR
(where the built entry point imports unbundled `@astrojs/*` packages).
For Deno applications the generated container runs `deno task <scriptName>` and copies the populated
`DENO_DIR` cache from the build stage, so whatever the build resolved is already present at runtime.
Unlike the Node.js and Bun package managers there is no separate production install step, because the build
stage runs `deno install` and `DENO_DIR` is carried forward as-is rather than being pruned.
`deno install` only resolves the dependencies declared in `deno.json` or `package.json`. An
import written as a bare specifier in source, such as `import { assert } from "jsr:@std/assert"`, is not
declared anywhere the installer can see, so it is fetched on first use and the container needs network access
at startup. The same applies to anything reachable only from inside the build script's own task command, which
Aspire cannot inspect. Add those imports to the `imports` map in `deno.json` if the container has to
start without network access.
For frameworks that produce a self-contained server artifact that does not require `node_modules`,
use `PublishAsNodeServer` instead for a smaller runtime image.

## Definition

```go
type JavaScriptAppResource interface {
    // ... omitted for brevity
    PublishAsPackageScript(options ...*PublishAsPackageScriptOptions) JavaScriptAppResource
}
```

## Signature

```go
PublishAsPackageScript(options ...*PublishAsPackageScriptOptions) JavaScriptAppResource
```

## Parameters

- `options` (`...*PublishAsPackageScriptOptions`) -- optional settings, see [Options](#options)

## Options

Optional parameters are passed in a trailing `options ...*PublishAsPackageScriptOptions` argument.

- `ScriptName` (`*string`) -- The name of the script to run in the published container. For Node.js and Bun applications this is a `package.json` script; for Deno applications it is a task defined in `deno.json`. For example, `start` invokes the configured package manager's run command for the `start` script, such as `npm run start`, `pnpm run start`, `yarn run start`, `bun run start`, or `deno task start`.
- `RunScriptArguments` (`*string`) -- Optional arguments appended after the script name at runtime, such as `-- --port "$PORT"`.

## Returns

[`JavaScriptAppResource`](/reference/api/go/aspire.hosting.javascript/javascriptappresource.md) -- The updated resource builder.

Returns a handle; failures surface later via `Err()`.

## Defined on

- [JavaScriptAppResource](/reference/api/go/aspire.hosting.javascript/javascriptappresource.md) -- `handle`
