# resolve-file [![NPM version](https://img.shields.io/npm/v/resolve-file.svg?style=flat)](https://www.npmjs.com/package/resolve-file) [![NPM downloads](https://img.shields.io/npm/dm/resolve-file.svg?style=flat)](https://npmjs.org/package/resolve-file) [![Linux Build Status](https://img.shields.io/travis/doowb/resolve-file.svg?style=flat&label=Travis)](https://travis-ci.org/doowb/resolve-file) [![Windows Build Status](https://img.shields.io/appveyor/ci/doowb/resolve-file.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/doowb/resolve-file) > Resolve an absolute file path from local directories, local node_modules or global node_modules. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save resolve-file ``` ## Usage ```js var resolveFile = require('resolve-file'); ``` ## API ### [resolve](index.js#L33) Resolve the path to a file located in one of the following places: * local to the current project (`'./index.js'`) * absolute (`'/usr/something.rc'`) * node module "main" file (`'cwd'`) * specific file inside a node module (`'cwd/LICENSE'`) * file located in user's home directory (`'~/.npmrc'`) **Example** ```js var fp = resolve('./index.js') //=> /path/to/resolve-file/index.js ``` **Params** * `name` **{String}**: Filename to resolve * `options` **{Object}**: Additional options to specify `cwd` * `returns` **{String}**: Resolved `filepath` if found ### [.file](index.js#L61) Resolve the path to a file located in one of the following places: * local to the current project (`'./index.js'`) * absolute (`'/usr/something.rc'`) * node module "main" file (`'cwd'`) * specific file inside a node module (`'cwd/LICENSE'`) * file located in user's home directory (`'~/.npmrc'`) **Example** ```js var file = resolve.file('./index.js') //=> { //=> cwd: '/path/to/resolve-file', //=> path: '/path/to/resolve-file/index.js' //=> } ``` **Params** * `name` **{String}**: Filename to resolve * `options` **{Object}**: Additional options to specify `cwd` * `returns` **{Object}**: File object with resolved `path` if found. ## About ### Related projects * [cwd](https://www.npmjs.com/package/cwd): Easily get the CWD (current working directory) of a project based on package.json, optionally starting… [more](https://github.com/jonschlinkert/cwd) | [homepage](https://github.com/jonschlinkert/cwd "Easily get the CWD (current working directory) of a project based on package.json, optionally starting from a given path. (node.js/javascript util)") * [expand-tilde](https://www.npmjs.com/package/expand-tilde): Bash-like tilde expansion for node.js. Expands a leading tilde in a file path to the… [more](https://github.com/jonschlinkert/expand-tilde) | [homepage](https://github.com/jonschlinkert/expand-tilde "Bash-like tilde expansion for node.js. Expands a leading tilde in a file path to the user home directory, or `~+` to the cwd.") * [look-up](https://www.npmjs.com/package/look-up): Faster drop-in replacement for find-up and findup-sync. | [homepage](https://github.com/jonschlinkert/look-up "Faster drop-in replacement for find-up and findup-sync.") * [resolve](https://www.npmjs.com/package/resolve): resolve like require.resolve() on behalf of files asynchronously and synchronously | [homepage](https://github.com/substack/node-resolve#readme "resolve like require.resolve() on behalf of files asynchronously and synchronously") ### Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). ### Contributors | **Commits** | **Contributor**
| | --- | --- | | 13 | [doowb](https://github.com/doowb) | | 7 | [jonschlinkert](https://github.com/jonschlinkert) | ### Building docs _(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ To generate the readme and API documentation with [verb](https://github.com/verbose/verb): ```sh $ npm install -g verb verb-generate-readme && verb ``` ### Running tests Install dev dependencies: ```sh $ npm install -d && npm test ``` ### Author **Brian Woodward** * [github/doowb](https://github.com/doowb) * [twitter/doowb](http://twitter.com/doowb) ### License Copyright © 2016, [Brian Woodward](https://github.com/doowb). Released under the [MIT license](LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 19, 2016._