Rush StackShopBlogEvents
Skip to main content

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 


allowedAlternativeVersionsreadonlyMap<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.
filePathreadonlystringGet the absolute file path of the common-versions.json file.
implicitlyPreferredVersionsreadonlyboolean | 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.

preferredVersionsreadonlyMap<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.


getAllPreferredVersions()Returns preferredVersions.
getPreferredVersionsHash()Get a sha1 hash of the preferred versions.
loadFromFile(jsonFilename)staticLoads 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().