# npm-programmatic

> Use NPM commands programmatically

Latest version **0.0.12** (published 2019-04-27) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Warnings: low downloads; no types; no esm support; has vulnerabilities; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.12 |
| Published | 2019-04-27 |
| First published | 2016-06-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 1 |
| Install scripts | no |
| GitHub stars | 93 |
| Author | manak |
| Maintainers | manak |
| Keywords | NPM, Programmatic, npm, programmatic |

## Links

- npm: https://www.npmjs.com/package/npm-programmatic
- Repository: https://github.com/Manak/npm-programmatic
- Homepage: https://github.com/Manak/npm-programmatic#readme
- Issues: https://github.com/Manak/npm-programmatic/issues
- npm.io page: https://npm.io/package/npm-programmatic

## Dependencies (1)

- [bluebird](https://npm.io/package/bluebird.md) ^3.4.1

## Recent versions

- 0.0.12 (latest) — 2019-04-27
- 0.0.11 — 2018-07-14
- 0.0.10 — 2018-01-05
- 0.0.9 — 2017-11-04
- 0.0.8 — 2017-04-26
- 0.0.7 — 2017-02-05
- 0.0.6 — 2016-09-15
- 0.0.5 — 2016-08-24
- 0.0.4 — 2016-06-23
- 0.0.3 — 2016-06-23
- 0.0.2 — 2016-06-23
- 0.0.1 — 2016-06-23

## README

# npm-programmatic [![Build Status](https://travis-ci.org/Manak/npm-programmatic.svg?branch=master)](https://travis-ci.org/Manak/npm-programmatic)   
[![NPM](https://nodei.co/npm/npm-programmatic.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/npm-programmatic/)    

npm-programmatic is a library that allows you to access npm commands programmatically from javascript
## Usage
Every function returns a Bluebird promise.   
CWD refers to current working directory, allowing you to ensure the command executes in a certain folder in the filesystem.
If output is set, the output of npm will be shown in the console.

## Installation of Packages

``` 
    npm.install(packages, opts).then(function)
```
| Name        | Type           | Value  |
| ------------- |:-------------:| -----:|
| packages      | Array      |   packages to be installed |
| opts      | Object | save:true/false; global:true/false; cwd:string; saveDev:true/false; noOptional:true/false; legacyBundling: true/false; output:true/false|

### Example
``` 
    var npm = require('npm-programmatic');
    npm.install(['left-pad'], {
        cwd:'/path/to/my/project',
        save:true
    })
    .then(function(){
        console.log("SUCCESS!!!");
    })
    .catch(function(){
        console.log("Unable to install package");
    });
```

## Unistallation of Packages

``` 
    npm.uninstall(packages, opts).then(function)
```
| Name        | Type           | Value  |
| ------------- |:-------------:| -----:|
| packages      | Array      |   packages to be uninstalled |
| opts      | Object | save:true/false; global:true/false; cwd:string; saveDev:true/false; output:true/false|

### Example
``` 
    var npm = require('npm-programmatic');
    npm.uninstall(['left-pad'], {
        cwd:'/path/to/my/project',
        save:true
    })
    .then(function(){
        console.log("SUCCESS!!!");
    })
    .catch(function(){
        console.log("Unable to uninstall package");
    });
```


## List Installed Packages

``` 
    npm.list(path).then(function)
```
| Name        | Type           | Value  |
| ------------- |:-------------:| -----:|
| path      | String      |   path at which to look |

### Example
``` 
    var npm = require('npm-programmatic');
    npm.list('/path/to/project')
    .then(function(arrayOfPackages){
        console.log(arrayOfPackages);
    })
    .catch(function(){
        console.log("Unable to uninstall package");
    });
```

## Tests
install mocha and dev dependencies. Then run 
``` npm test    ```

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