import-global
v1.1.1
Published
Import a globally installed module
Downloads
390,925
Maintainers
Readme
import-global
Import a globally installed module
Please don't use this unless absolutely necessary. Local dependencies should be preferred.
Install
npm install import-global
Usage
npm install --global cat-names
import {importGlobal} from 'import-global';
const {default: catNames} = await importGlobal('cat-names');
catNames.random();
//=> 'Snuggles'
API
importGlobal(moduleName)
Throws if the module cannot be found.
importGlobalSilent(moduleName)
Returns undefined
instead of throwing if the module cannot be found.
moduleName
Type: string
What you would use in import()
.
Related
- resolve-global - Resolve the path of a globally installed module
- import-from - Import a module from a given path
- resolve-from - Resolve the path of a module from a given path
- is-installed-globally - Check if your package was installed globally
- global-directory - Get the directory of globally installed packages and binaries