Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxleiko/exec-npm
Executes npm commands within a child_process fork in order to prevent npm to take too much memory
https://github.com/maxleiko/exec-npm
Last synced: 7 days ago
JSON representation
Executes npm commands within a child_process fork in order to prevent npm to take too much memory
- Host: GitHub
- URL: https://github.com/maxleiko/exec-npm
- Owner: maxleiko
- License: mit
- Created: 2015-11-02T15:57:16.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-04T11:26:07.000Z (about 9 years ago)
- Last Synced: 2024-10-04T00:45:54.945Z (about 1 month ago)
- Language: JavaScript
- Size: 145 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# exec-npm
Executes npm within a child_process spawn in order to prevent npm to take too much memory in the current one.
*This module has been created to free the [Kevoree Node.js runtime](https://github.com/kevoree/kevoree-nodejs-runtime) from npm's heavy memory usage.*** :warning: This module needs to be able to access the `npm` executable in the PATH (if you have npm installed globally, then it should be ok)**
### Installation
```sh
npm i exec-npm --save
```### Usage
```js
var execNpm = require('exec-npm');// arguments to give to npm client
// this is equivalent to a call to:
// $ cd /where/to/install/modules
// $ npm install minimist async express
var cmd = [ 'install', 'minimist', 'async', 'express', '--prefix=/where/to/install/modules' ];execNpm(cmd, function (err) {
if (err) {
console.log('Something went wrong: '+err.message);
} else {
console.log('Success');
}
});
```
> **NB.** When you specify a `prefix`, `npm` will always append to it the `node_modules` folder.### API
**execNpm(args, options, callback)**: *Function*
- args: *Array* - command-line arguments to give to the **npm** client (see npm's help)
- options (optional): *Object* - child_process spawn options
- callback: *Function* - a function to be called when the process is done (first parameter is the error, if any)