@springernature/util-package-installer

1.0.0 • Public • Published

Package Installer

NPM version Node version MIT License

This package allows dynamic installation of other NPM packages.

Internally it uses node's child_process.spawn because the recommended way of installing node modules dynamically is to use npm directly.

It has one dependency and is intended to be as light as possible.

It does not accept npm v1-style package names. If you don't know what they are, don't worry because they are old :)

Sample, simple usage (async/await style)

The general idea is to pass it a JSON.parsed package.json; It will either return stdout, or throw an Error.

const install = require('@springernature/util-package-installer');
const packageJSON = require('./path/to/package.json');
(async () => {
    let installResult;
    try {
        installResult = await install.dependencies(packageJSON);
        console.log(`npm install stdout: ${installResult}`);
    } catch (error) {
        console.log(`npm install stderr: ${error}`);
    }
})();

There are also helper methods to install just devDependencies or peerDependencies, please see the full documentation in this repo.

License

MIT License © 2019, Springer Nature

Package Sidebar

Install

npm i @springernature/util-package-installer

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

9.54 kB

Total Files

4

Last publish

Collaborators

  • ndv3997
  • sndigital
  • rseidelsohn
  • testingsabrina
  • roshandeorukhkar-sn
  • benjclark
  • sonniesedge
  • rlau
  • dotcode
  • joseluisbolos
  • hollsk
  • moddular
  • jpw
  • nickcall
  • howlingmad
  • davidpauljunior
  • morgaan