Socket
Socket
Sign inDemoInstall

npm-programmatic

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-programmatic

Use NPM commands programmatically


Version published
Weekly downloads
2.6K
increased by23.48%
Maintainers
1
Weekly downloads
 
Created
Source

npm-programmatic Build Status

NPM

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)
NameTypeValue
packagesArraypackages to be installed
optsObjectsave: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)
NameTypeValue
packagesArraypackages to be uninstalled
optsObjectsave: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)
NameTypeValue
pathStringpath 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

Keywords

FAQs

Package last updated on 27 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc