node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org »

packagefile-editor

package.json File Editor

An API to add Dependencies to a package.json file without installing them.

Installation

npm install packagefile-editor --save

Example

var Editor = require('packagefile-editor');
 
var package = new Editor();
 
package.addDependencies(['express']);
package.addDevDependencies(['mocha']);
 
package.writeFile();

API

new PackagefileEditor( content )

Constructor, creates a new editor instance. Predefined package.json file content can be passed in, else an empty content set will be used.

editor.addDependencies( dependencies )

Add dependencies to the package.json file. Version or tag of the dependency can be added as on npm install.

editor.addDependencies(['express', 'mongoose@3.9.0]);

editor.addDevDependencies( devDependencies )

Same as addDependencies, only adds devDependencies.

editor.writeFile( name )

Writes the new package.json file. An optional name can be passed in.

editor.writeFile();

Licence

Copyright (c) 2014 FallenRiteMonk Licensed under the MIT license.