Rush StackShopBlogEvents
Skip to main content

Home > @microsoft/rush-lib > PackageJsonEditor

PackageJsonEditor class

Signature:

export declare class PackageJsonEditor 

Remarks

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the PackageJsonEditor class.

Properties

PropertyModifiersTypeDescription
dependencyListreadonlyReadonlyArray<PackageJsonDependency>The list of dependencies of type DependencyType.Regular, DependencyType.Optional, or DependencyType.Peer.
devDependencyListreadonlyReadonlyArray<PackageJsonDependency>The list of dependencies of type DependencyType.Dev.
filePathreadonlystring
namereadonlystring
resolutionsListreadonlyReadonlyArray<PackageJsonDependency>This field is a Yarn-specific feature that allows overriding of package resolution.
versionreadonlystring

Methods

MethodModifiersDescription
addOrUpdateDependency(packageName, newVersion, dependencyType)
fromObject(object, filename)static
load(filePath)static
removeDependency(packageName, dependencyType)
saveIfModified()
saveToObject()Get the normalized package.json that represents the current state of the PackageJsonEditor. This method does not save any changes that were made to the package.json, but instead returns the object representation of what would be saved if saveIfModified() is called.
tryGetDependency(packageName)
tryGetDevDependency(packageName)