---
title: "@vltpkg/run: Reference — vlt docs"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/api-reference/run/reference"
image: "https://docs.vlt.io/og/client/api-reference/run/reference"
lang: "en"
---

# Reference

## Type Aliases

### ExecOptions

```ts
type ExecOptions = SharedOptions & object;
```

Defined in: index.ts:173

Options for exec() and execFG()

#### Type declaration

| Name   | Type     | Description            |
| ------ | -------- | ---------------------- |
| `arg0` | `string` | the command to execute |

---

### RunExecOptions

```ts
type RunExecOptions = SharedOptions & object;
```

Defined in: index.ts:181

Options for runExec() and runExecFG()

#### Type declaration

| Name           | Type                                                                                            | Description                                                                                                                                           |
| -------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `arg0`         | `string`                                                                                        | Either the command to be executed, or the event to be run                                                                                             |
| `packageJson`? | [`PackageJson`](https://docs.vlt.io/client/api-reference/package-json/reference.md#packagejson) | pass in a @vltpkg/package-json.PackageJson instance, and it'll be used for reading the package.json file. Optional, may improve performance somewhat. |

---

### RunFGResult

```ts
type RunFGResult = SpawnResultNoStdio & object;
```

Defined in: index.ts:214

Return type of [runFG](https://docs.vlt.io/client/api-reference/run/reference.md#runfg)

#### Type declaration

| Name    | Type                                                                                                           |
| ------- | -------------------------------------------------------------------------------------------------------------- |
| `post`? | [`SpawnResultNoStdio`](https://docs.vlt.io/client/api-reference/promise-spawn/reference.md#spawnresultnostdio) |
| `pre`?  | [`SpawnResultNoStdio`](https://docs.vlt.io/client/api-reference/promise-spawn/reference.md#spawnresultnostdio) |

---

### RunOptions

```ts
type RunOptions = SharedOptions & object;
```

Defined in: index.ts:138

Options for run() and runFG()

#### Type declaration

| Name             | Type                                                                                                                                           | Description                                                                                                                                           |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `arg0`           | `string`                                                                                                                                       | the name of the thing in package.json#scripts                                                                                                         |
| `ignoreMissing`? | `boolean`                                                                                                                                      | if the script is not defined in package.json#scripts, just ignore it and treat as success. Otherwise, treat as an error. Default false.               |
| `ignorePrePost`? | `boolean`                                                                                                                                      | skip the pre/post commands, just run the one specified. This can be used to run JUST the specified script, without any pre/post commands.             |
| `manifest`?      | `Pick`<[`Manifest`](https://docs.vlt.io/client/api-reference/types/reference.md#manifest), `"scripts"` \| `"gypfile"` \| `"hasInstallScript"`> | Pass in a manifest to avoid having to read it at all                                                                                                  |
| `packageJson`?   | [`PackageJson`](https://docs.vlt.io/client/api-reference/package-json/reference.md#packagejson)                                                | pass in a @vltpkg/package-json.PackageJson instance, and it'll be used for reading the package.json file. Optional, may improve performance somewhat. |

---

### RunResult

```ts
type RunResult = SpawnResultStdioStrings & object;
```

Defined in: index.ts:208

Return type of [run](https://docs.vlt.io/client/api-reference/run/reference.md#run)

#### Type declaration

| Name    | Type                                                                                                                     |
| ------- | ------------------------------------------------------------------------------------------------------------------------ |
| `post`? | [`SpawnResultStdioStrings`](https://docs.vlt.io/client/api-reference/promise-spawn/reference.md#spawnresultstdiostrings) |
| `pre`?  | [`SpawnResultStdioStrings`](https://docs.vlt.io/client/api-reference/promise-spawn/reference.md#spawnresultstdiostrings) |

---

### SharedOptions

```ts
type SharedOptions = PromiseSpawnOptions & object;
```

Defined in: index.ts:102

options shared by run() and exec()

#### Type declaration

| Name            | Type                  | Description                                                                                                                                                                                                                                                                                                                                                               |
| --------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `args`?         | `string`\[]           | additional arguments to pass to the command                                                                                                                                                                                                                                                                                                                               |
| `color`?        | `boolean`             | If true, then `FORCE_COLOR=1` will be set in the environment so that scripts will typically have colored output enablled, even if the output is not a tty.                                                                                                                                                                                                                |
| `cwd`           | `string`              | the directory where the package.json lives and the script runs                                                                                                                                                                                                                                                                                                            |
| `env`?          | `NodeJS.ProcessEnv`   | environment variables to set. `process.env` is always included, to omit fields, set them explicitly to undefined. vlt will add some of its own, as well: - npm_lifecycle_event: the event name - npm_lifecycle_script: the command in package.json#scripts - npm_package_json: path to the package.json file - VLT\_\* envs for all vlt configuration values that are set |
| `projectRoot`   | `string`              | the root of the project, which we don't walk up past                                                                                                                                                                                                                                                                                                                      |
| `script-shell`? | `boolean` \| `string` | the shell to run the script in. If not set, then the default platform-specific shell will be used.                                                                                                                                                                                                                                                                        |

## Variables

### npmConfigUserAgent

```ts
const npmConfigUserAgent: string = userAgent;
```

Defined in: index.ts:29

The user agent string set as `npm_config_user_agent` in lifecycle script environments. Matches the `user-agent` header sent with registry requests.

## Functions

### exec()

```ts
function exec(options): Promise<SpawnResultStdioStrings>
```

Defined in: index.ts:411

Execute an arbitrary command in the background

#### Parameters

| Parameter | Type                                                                                   |
| --------- | -------------------------------------------------------------------------------------- |
| `options` | [`ExecOptions`](https://docs.vlt.io/client/api-reference/run/reference.md#execoptions) |

#### Returns

`Promise`<[`SpawnResultStdioStrings`](https://docs.vlt.io/client/api-reference/promise-spawn/reference.md#spawnresultstdiostrings)>

---

### execFG()

```ts
function execFG(options): Promise<SpawnResultNoStdio>
```

Defined in: index.ts:459

Execute an arbitrary command in the foreground

#### Parameters

| Parameter | Type                                                                                   |
| --------- | -------------------------------------------------------------------------------------- |
| `options` | [`ExecOptions`](https://docs.vlt.io/client/api-reference/run/reference.md#execoptions) |

#### Returns

`Promise`<[`SpawnResultNoStdio`](https://docs.vlt.io/client/api-reference/promise-spawn/reference.md#spawnresultnostdio)>

---

### getNodeGypShim()

```ts
function getNodeGypShim(): Promise<string>
```

Defined in: node-gyp.ts:13

Get or create the node-gyp shim file path The shim redirects node-gyp calls to vlx node-gyp@latest

#### Returns

`Promise`<`string`>

---

### getNodeGypShimDir()

```ts
function getNodeGypShimDir(): Promise<string>
```

Defined in: node-gyp.ts:57

Get the directory containing the node-gyp shim This can be prepended to PATH to make the shim available

#### Returns

`Promise`<`string`>

---

### hasNodeGypBinding()

```ts
function hasNodeGypBinding(cwd): boolean
```

Defined in: node-gyp.ts:72

Check if a binding.gyp file exists

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `cwd`     | `string` |

#### Returns

`boolean`

---

### hasNodeGypReference()

```ts
function hasNodeGypReference(command): boolean
```

Defined in: node-gyp.ts:65

Check if a command contains node-gyp references

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `command` | `string` |

#### Returns

`boolean`

---

### isRunResult()

```ts
function isRunResult(v): v is RunResult
```

Defined in: index.ts:219

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `v`       | `unknown` |

#### Returns

`v is RunResult`

---

### run()

```ts
function run(options): Promise<RunResult>
```

Defined in: index.ts:197

Run a package.json#scripts event in the background

#### Parameters

| Parameter | Type                                                                                 |
| --------- | ------------------------------------------------------------------------------------ |
| `options` | [`RunOptions`](https://docs.vlt.io/client/api-reference/run/reference.md#runoptions) |

#### Returns

`Promise`<[`RunResult`](https://docs.vlt.io/client/api-reference/run/reference.md#runresult)>

---

### runExec()

```ts
function runExec(options): Promise<
  | SpawnResultStdioStrings
| RunResult>
```

Defined in: index.ts:534

If the arg0 is a defined package.json script, then run(), otherwise exec()

#### Parameters

| Parameter | Type                                                                                         |
| --------- | -------------------------------------------------------------------------------------------- |
| `options` | [`RunExecOptions`](https://docs.vlt.io/client/api-reference/run/reference.md#runexecoptions) |

#### Returns

`Promise`< | [`SpawnResultStdioStrings`](https://docs.vlt.io/client/api-reference/promise-spawn/reference.md#spawnresultstdiostrings) | [`RunResult`](https://docs.vlt.io/client/api-reference/run/reference.md#runresult)>

---

### runExecFG()

```ts
function runExecFG(options): Promise<
  | SpawnResultNoStdio
| RunFGResult>
```

Defined in: index.ts:543

If the arg0 is a defined package.json script, then runFG(), otherwise execFG()

#### Parameters

| Parameter | Type                                                                                         |
| --------- | -------------------------------------------------------------------------------------------- |
| `options` | [`RunExecOptions`](https://docs.vlt.io/client/api-reference/run/reference.md#runexecoptions) |

#### Returns

`Promise`< | [`SpawnResultNoStdio`](https://docs.vlt.io/client/api-reference/promise-spawn/reference.md#spawnresultnostdio) | [`RunFGResult`](https://docs.vlt.io/client/api-reference/run/reference.md#runfgresult)>

---

### runFG()

```ts
function runFG(options): Promise<RunFGResult>
```

Defined in: index.ts:203

Run a package.json#scripts event in the foreground

#### Parameters

| Parameter | Type                                                                                 |
| --------- | ------------------------------------------------------------------------------------ |
| `options` | [`RunOptions`](https://docs.vlt.io/client/api-reference/run/reference.md#runoptions) |

#### Returns

`Promise`<[`RunFGResult`](https://docs.vlt.io/client/api-reference/run/reference.md#runfgresult)>
