# Using npm packages and local dependencies - Checkly Docs

> Use npm packages and local JavaScript or TypeScript files in your checks, and see how dependencies differ between Checkly runtimes and Playwright Check Suites.

Source: https://www.checklyhq.com/docs/cli/dependencies/

---

Back to top
- npm packages Browser, Multistep, and API checks
- Playwright Check Suites

- Local Dependencies

Getting Started

# Using npm packages and local dependencies

Use npm packages and local JavaScript or TypeScript files in your checks, and see how dependencies differ between Checkly runtimes and Playwright Check Suites.

Checkly lets you use JavaScript and TypeScript in your [Browser](https://www.checklyhq.com/docs/detect/synthetic-monitoring/browser-checks/overview) and [Multistep](https://www.checklyhq.com/docs/detect/synthetic-monitoring/multistep-checks/overview) checks, [API check setup and teardown scripts](https://www.checklyhq.com/docs/detect/synthetic-monitoring/api-checks/setup-and-teardown), and [Playwright Check Suites](https://www.checklyhq.com/docs/detect/synthetic-monitoring/playwright-checks/overview). Checks can use npm packages and import local JavaScript and TypeScript files.
How dependencies work depends on the check type:
Check type Dependency model Environment field

Browser checks and Multistep checks Run in a Checkly runtime with fixed Checkly-provided dependencies `runtimeId`

Playwright Check Suites Install dependencies from your project files, including `package.json` and your lock file `engine`

Use `runtimeId` to choose a custom Checkly runtime for Browser checks and Multistep checks. Use `engine` only for Playwright Check Suites, where it overrides the JavaScript engine version that runs your own Playwright project.

## npm packages

### Browser, Multistep, and API checks

Not all npm packages are available in a Checkly runtime.

The JavaScript code for these check types executes in a runtime environment managed by Checkly.
Runtime versions can be selected by setting a `runtimeId`.
You can configure `runtimeId` at the check and group level using constructs, and set a project default in the [project configuration file](https://www.checklyhq.com/docs/constructs/project#param-checks-runtime-id).
A runtime pins a Node.js version and a fixed set of npm packages, such as:

- `@playwright/test`

- `axios`

- `lodash`

- `moment`

The [runtime specification](https://www.checklyhq.com/docs/platform/runtimes/runtime-specification) lists the exact versions in each runtime.

- [Learn more about runtimes](https://www.checklyhq.com/docs/platform/runtimes/overview)

- [Why can’t I import any npm package or other third-party dependencies?](https://www.checklyhq.com/docs/platform/runtimes/overview)

### Playwright Check Suites

Playwright Check Suites do not use Checkly runtimes. Instead, Checkly installs your project’s dependencies from your `package.json` and lock file. This lets you use any [dependencies](https://www.checklyhq.com/docs/detect/synthetic-monitoring/playwright-checks/dependencies/), including private packages or packages from a custom registry.
Use the `engine` field to override the JavaScript engine version for a Playwright Check Suite. `engine` does not select a Checkly runtime or a fixed package set.

## Local Dependencies

Your checks can also import other JavaScript and TypeScript files as dependencies.
This is useful for defining helper functions to be reused across multiple checks.
The Checkly CLI automatically detects these dependencies and bundles them with the check.
No additional configuration is needed.
Here is a [Browser check](https://www.checklyhq.com/docs/detect/synthetic-monitoring/browser-checks/overview) example of how this works in practice.
The directory tree looks like the following:

```
__checks__
├── login.check.ts
├── login.spec.ts
└── login-helper.ts
```

`login-helper.ts` defines a function `gitHubLogin` that can be used by multiple Browser checks.
login-helper.ts

```
export async function gitHubLogin (page, username, password) {
await page.goto('https://github.com/login')
await page.getByLabel('Username or email address').type(username)
await page.getByLabel('Password').type(password)
await page.getByRole('button', { name: 'Sign in' })
}
```

In `login.spec.ts` we define the actual Playwright test. This file can import the `gitHubLogin` function from `login-helper.ts`.
It also reads the username and password from [remote environment variables](https://www.checklyhq.com/docs/cli/environment-variables#remote-environment-variables).
login.spec.ts

```
// @ts-ignore
import { test } from '@playwright/test'
import { gitHubLogin } from './login-helper'

test('Github login', async ({ page }) => {
await gitHubLogin(page, process.env.GITHUB_USER, process.env.GITHUB_PWD)

// your normal check code
await page.click('.header-search-input')
})
```

`login.check.ts` initializes a new [BrowserCheck construct](https://www.checklyhq.com/docs/constructs/browser-check). Note that it’s only necessary to configure the main Playwright file `login.spec.ts`. The `login-helper.ts` dependency is automatically detected by the CLI.
login.check.ts

```
import { BrowserCheck } from 'checkly/constructs'

new BrowserCheck('login-check', {
name: 'Login Check',
code: { entrypoint: './login.spec.ts' }
})
```

After running [`npx checkly deploy`](https://www.checklyhq.com/docs/cli/checkly-deploy), you can see in the Web UI that the helper file `login-helper.ts` was also uploaded for this Check.

The maximum total size of a Checkly project when deploying or running a test session, including local dependencies, is 40 MB.

Was this page helpful?

[Suggest edits](https://github.com/checkly/docs/edit/main/cli/dependencies.mdx)[Raise issue](https://github.com/checkly/docs/issues/new?title=Issue%20on%20docs&body=Path:%20/cli/dependencies)

[Environment variables Previous](https://www.checklyhq.com/docs/cli/environment-variables)[Attaching Git metadata Next](https://www.checklyhq.com/docs/cli/attaching-git-metadata)

[x](https://x.com/checklyhq)[github](https://github.com/checkly)[linkedin](https://linkedin.com/company/checkly)

[Powered by This documentation is built and hosted on Mintlify, a developer documentation platform](https://www.mintlify.com/?utm_campaign=poweredBy&utm_medium=referral&utm_source=checkly-422f444a)
