Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jonschlinkert/npm-paths

Returns an array of unique "npm" directories based on the user's platform and environment. Node.js / JavaScript.
https://github.com/jonschlinkert/npm-paths

filepath filepaths global install javascript jonschlinkert node nodejs npm paths resolve

Last synced: 15 days ago
JSON representation

Returns an array of unique "npm" directories based on the user's platform and environment. Node.js / JavaScript.

Awesome Lists containing this project

README

        

# npm-paths [![NPM version](https://img.shields.io/npm/v/npm-paths.svg?style=flat)](https://www.npmjs.com/package/npm-paths) [![NPM monthly downloads](https://img.shields.io/npm/dm/npm-paths.svg?style=flat)](https://npmjs.org/package/npm-paths) [![NPM total downloads](https://img.shields.io/npm/dt/npm-paths.svg?style=flat)](https://npmjs.org/package/npm-paths) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/npm-paths.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/npm-paths)

> Returns an array of NPM directory paths based on the user's platform and environment.

Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install --save npm-paths
```

This lib does not include the `require.main.paths` in the result array. If you do need the `require.main.paths`, use [global-paths](https://github.com/jonschlinkert/global-paths) instead.

## Usage

```js
const paths = require('./');
console.log(paths());

// specify the CWD to start from
console.log(paths('some/directory'));
```

## Example results

Results in something like the following:

**Mac**

```js
// example was run from the "/Users/jonschlinkert/dev/npm-paths/" directory
[ '/Users/jonschlinkert/dev/npm-paths/node_modules',
'/Users/jonschlinkert/dev/node_modules',
'/Users/jonschlinkert/node_modules',
'/Users/node_modules',
'/node_modules',
'/usr/local/lib/node_modules',
'/usr/lib/node_modules' ]
```

**Windows**

```js
// example was run from the "F:\\dev\\npm-paths" directory
[ 'C:\\Users\\SERVER\\AppData\\Roaming\\node_modules\\npm',
'C:\\Program Files\\nodejs\\node_modules',
'F:\\dev\\npm-paths\\node_modules',
'F:\\dev\\node_modules',
'F:\\node_modules' ]
```

## About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

Running Tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

```sh
$ npm install && npm test
```

Building docs

_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

### Related projects

You might also be interested in these projects:

* [global-modules](https://www.npmjs.com/package/global-modules): The directory used by npm for globally installed npm modules. | [homepage](https://github.com/jonschlinkert/global-modules "The directory used by npm for globally installed npm modules.")
* [global-paths](https://www.npmjs.com/package/global-paths): Returns an array of unique "global" directories based on the user's platform and environment. The… [more](https://github.com/jonschlinkert/global-paths) | [homepage](https://github.com/jonschlinkert/global-paths "Returns an array of unique "global" directories based on the user's platform and environment. The resulting paths can be used for doing lookups for generators or other globally installed npm packages. Node.js / JavaScript.")
* [global-prefix](https://www.npmjs.com/package/global-prefix): Get the npm global path prefix. | [homepage](https://github.com/jonschlinkert/global-prefix "Get the npm global path prefix.")

### Contributors

| **Commits** | **Contributor** |
| --- | --- |
| 13 | [jonschlinkert](https://github.com/jonschlinkert) |
| 2 | [loremaps](https://github.com/loremaps) |
| 1 | [doowb](https://github.com/doowb) |

### Author

**Jon Schlinkert**

* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)

### License

Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on December 15, 2018._