Skip to content

alidavut/require-g

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

require-g

This module enables you to load global modules in Node.js.

Usage

First install the module:

npm install require-g --save

Loading Modules

import requireG from 'require-g';
const MyGlobalModule = requireG('my-global-module');

MyGlobalModule.run();

Require Hook

You can override the require hook by using register module and use global:... prefix.

import 'require-g/register';
import MyGlobalModule from 'global:my-global-module';
// or require('global:my-global-module');

MyGlobalModule.run();

Get All Global Modules

You can get all global module names:

import requireG from 'require-g';
const globalModules = requireG.modules;

console.log(globalModules);

/*
will return ['mocha', 'gulp', ...]
*/

About

Import global modules in Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published