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
| Property | Modifiers | Type | Description |
|---|---|---|---|
| dependencyList | readonly | ReadonlyArray<PackageJsonDependency> | The list of dependencies of type DependencyType.Regular, DependencyType.Optional, or DependencyType.Peer. |
| devDependencyList | readonly | ReadonlyArray<PackageJsonDependency> | The list of dependencies of type DependencyType.Dev. |
| filePath | readonly | string | |
| name | readonly | string | |
| resolutionsList | readonly | ReadonlyArray<PackageJsonDependency> | This field is a Yarn-specific feature that allows overriding of package resolution. |
| version | readonly | string |
Methods
| Method | Modifiers | Description |
|---|---|---|
| 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) |