https://github.com/silverwind/globalrequire
INACTIVE - please use https://github.com/sindresorhus/import-global
https://github.com/silverwind/globalrequire
Last synced: 12 months ago
JSON representation
INACTIVE - please use https://github.com/sindresorhus/import-global
- Host: GitHub
- URL: https://github.com/silverwind/globalrequire
- Owner: silverwind
- License: bsd-2-clause
- Created: 2016-11-03T21:56:59.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-05-30T08:25:05.000Z (about 8 years ago)
- Last Synced: 2025-05-28T11:18:45.230Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 67.4 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# globalrequire
[](https://www.npmjs.org/package/globalrequire) [](https://www.npmjs.org/package/globalrequire) [](https://travis-ci.org/silverwind/globalrequire)
> require() globally installed modules
`globalrequire` is like `require` but for globally installed modules. Supports both [yarn](https://github.com/yarnpkg/yarn) and [npm](https://github.com/npm/npm)'s global locations, with a preference for yarn when in conflict. Will not attempt to do any fallback to local modules or `NODE_PATH`.
## Installation
```console
$ npm i --save globalrequire
```
## Example
```js
const globalrequire = require('globalrequire');
console.log(globalrequire('npm').version);
//=> '3.10.9'
console.log(globalrequire.resolve('npm'));
//=> '/Users/silverwind/.npm-global/lib/node_modules/npm'
```
## API
### globalrequire(module)
### globalrequire.resolve(module)
- `module` *String* - The module name. Will throw on invalid module names or relative requests.
© [silverwind](https://github.com/silverwind), distributed under BSD licence