import-global
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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().

Package Sidebar

Install

npm i import-global

Weekly Downloads

89,640

Version

1.1.0

License

MIT

Unpacked Size

3.58 kB

Total Files

4

Last publish

Collaborators

  • sindresorhus