Function: addDependenciesToPackageJson

addDependenciesToPackageJson(tree, dependencies, devDependencies, packageJsonPath?, keepExistingVersions?): GeneratorCallback

Add Dependencies and Dev Dependencies to package.json

For example:

1addDependenciesToPackageJson(tree, { react: 'latest' }, { jest: 'latest' }); 2

This will add react and jest to the dependencies and devDependencies sections of package.json respectively.


treeTreeTree representing file system to modify
dependenciesRecord<string, string>Dependencies to be added to the dependencies section of package.json
devDependenciesRecord<string, string>Dependencies to be added to the devDependencies section of package.json
packageJsonPath?stringPath to package.json
keepExistingVersions?booleanIf true, prevents existing dependencies from being bumped to newer versions



Callback to install dependencies only if necessary, no-op otherwise