Home > @microsoft/rush-lib > CommonVersionsConfiguration

CommonVersionsConfiguration class

Use this class to load and save the “common/config/rush/common-versions.json” config file. This config file stores dependency version information that affects all projects in the repo.


export declare class CommonVersionsConfiguration 


Property Modifiers Type Description
allowedAlternativeVersions   Map<string, ReadonlyArray<string>> A table that stores, for a given dependency, a list of SemVer ranges that will be accepted by “rush check” in addition to the normal version range.
filePath   string Get the absolute file path of the common-versions.json file.
implicitlyPreferredVersions   boolean | undefined When set to true, for all projects in the repo, all dependencies will be automatically added as preferredVersions, except in cases where different projects specify different version ranges for a given dependency. For older package managers, this tended to reduce duplication of indirect dependencies. However, it can sometimes cause trouble for indirect dependencies with incompatible peerDependencies ranges.If the value is undefined, then the default value is true.
preferredVersions   Map<string, string> A table that specifies a “preferred version” for a given NPM package. This feature is typically used to hold back an indirect dependency to a specific older version, or to reduce duplication of indirect dependencies.
xstitchPreferredVersions   Map<string, string> A table of specifies preferred versions maintained by the XStitch tool.


Method Modifiers Description
getAllPreferredVersions()   Returns the union of preferredVersions and xstitchPreferredVersions.
getPreferredVersionsHash()   Get a sha1 hash of the preferred versions.
loadFromFile(jsonFilename) static Loads the common-versions.json data from the specified file path. If the file has not been created yet, then an empty object is returned.
save()   Writes the “common-versions.json” file to disk, using the filename that was passed to loadFromFile().