# @cityssm/has-package

> Tests if a package is available to be imported. Useful for checking if optional dependencies are installed.

Latest version **1.0.0** (published 2024-12-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cityssm/has-package
pnpm add @cityssm/has-package
yarn add @cityssm/has-package
bun add @cityssm/has-package
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2024-12-18 |
| First published | 2024-11-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 13.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | The Corporation of the City of Sault Ste. Marie |
| Maintainers | dgowans |
| Keywords | dependency, dependencies, optional, import, require |

## Links

- npm: https://www.npmjs.com/package/@cityssm/has-package
- Repository: https://github.com/cityssm/node-has-package
- Homepage: https://github.com/cityssm/node-has-package#readme
- Issues: https://github.com/cityssm/node-has-package/issues
- npm.io page: https://npm.io/package/@cityssm/has-package

## Recent versions

- 1.0.0 (latest) — 2024-12-18
- 0.1.1 — 2024-11-21
- 0.1.0 — 2024-11-21

## README

# Has Package

[![NPM Version](https://img.shields.io/npm/v/%40cityssm%2Fhas-package)](https://www.npmjs.com/package/@cityssm/has-package)
[![Maintainability](https://api.codeclimate.com/v1/badges/d5e8bd61c386abe06f27/maintainability)](https://codeclimate.com/github/cityssm/node-has-package/maintainability)
[![DeepSource](https://app.deepsource.com/gh/cityssm/node-has-package.svg/?label=active+issues&show_trend=true&token=DR3479iXPgrcY5n3e5515lA-)](https://app.deepsource.com/gh/cityssm/node-has-package/)
[![codecov](https://codecov.io/gh/cityssm/node-has-package/graph/badge.svg?token=YG1D26SPQF)](https://codecov.io/gh/cityssm/node-has-package)

**Tests if a package is available to be imported. Useful for checking if optional dependencies are installed.**

Unlike other packages that test whether a package is available by importing it,
this package **checks the file system** for the corresponding `package.json` file.
This avoids any package code from running during the check.

## Installation

```sh
npm install @cityssm/has-package
```

## Usage

```javascript
import hasPackage from '@cityssm/has-package'

/*
 * Test for an existing package
 */

let packageExists = await hasPackage('eslint')
console.log(packageExists)
// => true

/*
 * Test for an nonexisting package
 */

packageExists = await hasPackage('@cityssm/non-existing-package')
console.log(packageExists)
// => false
```

---
_Source: https://npm.io/package/@cityssm/has-package · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
