RoadmapShopEvents
Skip to main content

Home > @microsoft/rush-lib > PackageJsonEditor

PackageJsonEditor class

Signature:

export declare class PackageJsonEditor 

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
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)