| hide_title | true |
|---|---|
| custom_edit_url | |
| pagination_prev | |
| pagination_next |
Home > @rushstack/node-core-library > PackageJsonLookup > tryGetPackageFolderFor
Returns the absolute path of a folder containing a package.json file, by looking upwards from the specified fileOrFolderPath. If no package.json can be found, undefined is returned.
Signature:
tryGetPackageFolderFor(fileOrFolderPath: string): string | undefined;|
Parameter |
Type |
Description |
|---|---|---|
|
fileOrFolderPath |
string |
a relative or absolute path to a source file or folder that may be part of a package |
Returns:
string | undefined
an absolute path to a folder containing a package.json file
The fileOrFolderPath is not required to actually exist on disk. The fileOrFolderPath itself can be the return value, if it is a folder containing a package.json file. Both positive and negative lookup results are cached.