npm-cache-path
Version:
Get the path of npm cache folder
48 lines (31 loc) • 1.36 kB
Markdown
# npm-cache-path
[](https://www.npmjs.com/package/npm-cache-path)
[](https://travis-ci.org/shinnn/npm-cache-path)
[](https://coveralls.io/github/shinnn/npm-cache-path?branch=master)
Get the path of [npm cache folder](https://docs.npmjs.com/cli/cache)
```javascript
const npmCachePath = require('npm-cache-path');
(async () => {
await npmCachePath(); //=> '/Users/shinnn/.npm'
})();
```
## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).
```
npm install npm-cache-path
```
## API
```javascript
const npmCachePath = require('npm-cache-path');
```
### npmCachePath()
Return: `Promise<string>`
It tries to get the path of [npm](https://docs.npmjs.com/getting-started/what-is-npm) cache folder, first [from the environment variables](https://github.com/shinnn/npm-cache-env), second from the stdout of [`npm config get cache`](https://docs.npmjs.com/cli/config#get) command.
```javascript
// npm_config_cache=/foo/bar node ./example.js
(async () => {
await npmCachePath(); //=> '/foo/bar'
})();
```
## License
[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe