https://github.com/mrmlnc/npm-module-path
:package: Get the path of the given package(s) if it is installed globally or locally.
https://github.com/mrmlnc/npm-module-path
Last synced: about 1 year ago
JSON representation
:package: Get the path of the given package(s) if it is installed globally or locally.
- Host: GitHub
- URL: https://github.com/mrmlnc/npm-module-path
- Owner: mrmlnc
- License: mit
- Created: 2016-07-18T12:52:54.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-04T17:53:24.000Z (about 9 years ago)
- Last Synced: 2025-04-25T23:47:26.719Z (over 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# npm-module-path
> Get the path of the given package(s) if it is installed globally or locally.
[](https://travis-ci.org/mrmlnc/npm-module-path)
[](https://ci.appveyor.com/project/mrmlnc/npm-module-path)
## Install
```shell
$ npm i -S npm-module-path
```
## Why?
Primarily, this module is designed to search modules for VS Code (Language Server Extensions, etc).
* Dependencies free.
* Returns the path to the module directory (without `require`).
* Can work with an array of dependencies.
## Usage
```js
const nmp = require('npm-module-path');
nmp.resolveOne('mocha').then((filepath) => {
console.log(filepath); // ['/home/travis/.nvm/versions/node/v6.6.0/lib/node_modules/mocha']
});
nmp.resolveMany(['mocha', 'tslint']).then((filepaths) => {
console.log(filepaths); // ['node_modules/mocha', '/usr/lib/node_modules/tslint']
});
```
## resolveOne(toResolve: string, root?: string, options?: IResolveOptions)
## resolveMany(toResolve: string[], root?: string, options?: IResolveOptions)
## IResolveOptions
**cache**
* Type: `String`
* Default: `.`
The root directory of the project to search the module.
**resolveDir**
* Type: `Boolean`
* Default: `false`
Return the path to the directory where the module was found.
**resolveOnlyByPrefix**
* Type: `Boolean`
* Default: `false`
Skip search modules in the default directories and search them only by `npm config get prefix`.
## Changelog
See the [Releases section of our GitHub project](https://github.com/mrmlnc/npm-module-path/releases) for changelogs for each release version.
## License
This software is released under the terms of the MIT license.