Rush StackShopBlogEvents
Skip to main content

Home > @rushstack/node-core-library > Import > resolvePackage

Import.resolvePackage() method

Performs module resolution to determine the folder where a package is installed.

Signature:

static resolvePackage(options: IImportResolvePackageOptions): string;

Parameters

ParameterTypeDescription
optionsIImportResolvePackageOptions

Returns:

string

the absolute path of the package folder. If IImportResolveOptions.includeSystemModules is specified and a system module is found, then its name is returned without any file path.

Remarks

Suppose example is an NPM package whose entry point is lib/index.js:

// Returns "/path/to/project/node_modules/example"
Import.resolvePackage({ packageName: 'example' });

If you need to resolve a module path, use Import.resolveModule() instead:

// Returns "/path/to/project/node_modules/example/lib/index.js"
Import.resolveModule({ modulePath: 'example' });