🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

npm-root

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-root

Get the node modules directory, a.k.a. npm root. Global or local.

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
7
-63.16%
Maintainers
1
Weekly downloads
 
Created
Source

npm-root

NPM version

Get the node modules directory, a.k.a. npm root. Global or local.

Installation

Install npm-root using npm:

npm install --save npm-root

Usage

Module usage

var npmRoot = require('npm-root');

// Get the local node_modules path:
npmRoot(function (err, localPath) {
  // ...
});

// Get the local node_modules path for another directory:
npmRoot({cwd: '/path/to/other/folder'}, function (err, localPath) {
  // ...
});

// Get the global node_modules path:
npmRoot({global: true}, function (err, globalPath) {
  // ...
});

API

npmRoot(opts, cb)

NameTypeDescription
optsObjectOptions (optional)
cbFunctionCallback function

opts.global

Set this to get the global node_modules path instead of the local.

opts.cwd

Change current working directory, affects only the local node_modules path.

License

MIT

Keywords

npm

FAQs

Package last updated on 06 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts