# WithNpm

- Module: [Aspire.Hosting.JavaScript](/reference/api/go/aspire.hosting.javascript.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`JavaScriptAppResource`](/reference/api/go/aspire.hosting.javascript/javascriptappresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Configures the Node.js resource to use npm as the package manager and optionally installs packages before the application starts.

## Definition

```go
func (JavaScriptAppResource) WithNpm(options ...*WithNpmOptions) JavaScriptAppResource
```

## Parameters

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

## Options

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

- `Install` (`*bool`) -- When true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
- `InstallCommand` (`*string`) -- The install command itself passed to npm to install dependencies.
- `InstallArgs` (`[]string`) -- The command-line arguments passed to npm to install dependencies.

## Returns

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

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

## Applies to

- [`BunAppResource`](/reference/api/go/aspire.hosting.javascript/bunappresource.md)
- [`DenoAppResource`](/reference/api/go/aspire.hosting.javascript/denoappresource.md)
- [`JavaScriptAppResource`](/reference/api/go/aspire.hosting.javascript/javascriptappresource.md)
- [`NextJsAppResource`](/reference/api/go/aspire.hosting.javascript/nextjsappresource.md)
- [`NodeAppResource`](/reference/api/go/aspire.hosting.javascript/nodeappresource.md)
- [`ViteAppResource`](/reference/api/go/aspire.hosting.javascript/viteappresource.md)
