RoadmapShopEvents
Skip to main content

Home > @microsoft/rush-lib > PackageJsonEditor

PackageJsonEditor class

Signature:
export declare class PackageJsonEditor

Properties

PropertyModifiersTypeDescription
dependencyListReadonlyArray<PackageJsonDependency >The list of dependencies of type DependencyType.Regular, DependencyType.Optional, or DependencyType.Peer.
devDependencyListReadonlyArray<PackageJsonDependency >The list of dependencies of type DependencyType.Dev.
filePathstring
namestring
resolutionsListReadonlyArray<PackageJsonDependency >This field is a Yarn-specific feature that allows overriding of package resolution.
versionstring

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)