Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dkundel/pkg-install
📦 A wrapper making installation of Node.js packages from code easier
https://github.com/dkundel/pkg-install
Last synced: 1 day ago
JSON representation
📦 A wrapper making installation of Node.js packages from code easier
- Host: GitHub
- URL: https://github.com/dkundel/pkg-install
- Owner: dkundel
- License: mit
- Created: 2019-02-19T00:48:28.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-30T14:32:03.000Z (7 months ago)
- Last Synced: 2024-11-02T21:31:46.220Z (6 days ago)
- Language: TypeScript
- Homepage: https://pkg-install.dkundel.com
- Size: 105 KB
- Stars: 26
- Watchers: 2
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-web-cn - pkg-install - 一个帮助你轻松地安装 npm 包,如果你的脚手架工具需要拉取代码并下载依赖,这个库会是个不错的选择 (Uncategorized / Uncategorized)
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](https://www.npmjs.com) and [yarn](https://www.yarnpkg.com)
- Easy to use promise-based API
- Uses [`execa`](https://www.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)):
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!