# pkg-install

> A wrapper making installation of Node.js packages from code easier

Latest version **1.0.0** (published 2019-03-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install pkg-install
pnpm add pkg-install
yarn add pkg-install
bun add pkg-install
```

## Health

**Score 25/100 (F)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-03-18 |
| First published | 2019-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 81.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Dominik Kundel |
| Maintainers | dkundel |
| Keywords | npm, yarn, install, cli, script |

## Links

- npm: https://www.npmjs.com/package/pkg-install
- Repository: https://github.com/dkundel/pkg-install
- Homepage: https://pkg-install.dkundel.com/
- Issues: https://github.com/dkundel/pkg-install/issues
- npm.io page: https://npm.io/package/pkg-install

## Dependencies (3)

- [execa](https://npm.io/package/execa.md) ^1.0.0
- [@types/node](https://npm.io/package/@types/node.md) ^11.9.4
- [@types/execa](https://npm.io/package/@types/execa.md) ^0.9.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-03-18
- 0.2.0 — 2019-02-19
- 0.1.1 — 2019-02-19
- 0.1.0 — 2019-02-19
- 0.0.5 — 2019-02-19
- 0.0.3 — 2019-02-19
- 0.0.2 — 2019-02-19

## README

[![npm](https://img.shields.io/npm/v/pkg-install.svg?style=flat-square)](https://npmjs.com/package/pkg-install) [![npm](https://img.shields.io/npm/dt/pkg-install.svg?style=flat-square)](https://npmjs.com/package/pkg-install) [![npm](https://img.shields.io/npm/l/pkg-install.svg?style=flat-square)](/LICENSE) [![Build Status](https://travis-ci.org/dkundel/pkg-install.svg?branch=master)](https://travis-ci.org/dkundel/pkg-install) ![Codecov](https://img.shields.io/codecov/c/gh/dkundel/pkg-install.svg?style=flat-square)
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)

# pkg-install

> Easier installation of Node.js packages irrespective of the platform or package manager.

- Supports [npm](npmjs.com) and [yarn](yarnpkg.com)
- Easy to use promise-based API
- Uses [`execa`](npm.im/execa) under the hood

## Installation

```bash
npm install pkg-install
```

## Usage

### Install a set of known dependencies to a project

```js
const { install } = require('pkg-install');

(async () => {
  const { stdout } = await install(
    {
      twilio: '^3.1',
      'node-env-run': '~1',
      'pkg-install': undefined,
    },
    {
      dev: true,
      prefer: 'npm',
    }
  );
  console.log(stdout);
})();
```

### Run a project install of dependencies

```js
const { projectInstall } = require('pkg-install');

(async () => {
  const { stdout } = await projectInstall({
    prefer: 'yarn',
  });
  console.log(stdout);
})();
```

### Documentation

Full documentation of available functions and configuration can be found on:
[pkg-install.dkundel.com](https://pkg-install.dkundel.com/modules/pkg_install.html)

## Known Issues

### 1. Disparity in supported flags

At the current moment `yarn` has no equivalent flags for `--save-bundle` or `--no-save`. These will be ignored when `yarn` has been detected as package manager.

The flags that were ignored in the run are returned as the `ignoredFlags` property.

### 2. Different behavior of modifying `package.json`

This library uses `npm` and `yarn` under the hood and currently `npm install` and `yarn add` have different behaviors when passing versions to the package names

For example

```bash
npm install twilio^3.1 node-env-run~1 pkg-install
```

Will result in the following dependencies in the `package.json`:

```json
"dependencies": {
  "node-env-run": "^1.0.1",
  "pkg-install": "^0.1.1",
  "twilio": "^3.28.1"
}
```

While:

```bash
yarn add twilio@^3.1 node-env-run@~1 pkg-install
```

Will result in the following dependencies in the `package.json`:

```json
"dependencies": {
  "node-env-run": "~1",
  "pkg-install": "^0.1.1",
  "twilio": "^3.1"
}
```

## License

MIT

## Contributors

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore -->
<table><tr><td align="center"><a href="https://dkundel.com"><img src="https://avatars3.githubusercontent.com/u/1505101?v=4" width="100px;" alt="Dominik Kundel"/><br /><sub><b>Dominik Kundel</b></sub></a><br /><a href="https://github.com/dkundel/pkg-install/commits?author=dkundel" title="Code">💻</a></td></tr></table>
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

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