# import-global

> Import a globally installed module

Latest version **1.1.1** (published 2024-01-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install import-global
pnpm add import-global
yarn add import-global
bun add import-global
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2024-01-10 |
| First published | 2017-06-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18 |
| Dependencies | 1 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 59 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | import, global, package, module, globally, npm, yarn, packages, require |

## Links

- npm: https://www.npmjs.com/package/import-global
- Repository: https://github.com/sindresorhus/import-global
- Homepage: https://github.com/sindresorhus/import-global#readme
- Issues: https://github.com/sindresorhus/import-global/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/import-global

## Dependencies (1)

- [resolve-global](https://npm.io/package/resolve-global.md) ^2.0.0

## Recent versions

- 1.1.1 (latest) — 2024-01-10
- 1.1.0 — 2023-11-06
- 1.0.0 — 2023-11-06
- 0.1.0 — 2017-06-25

## README

# import-global

> Import a globally installed module

**Please don't use this unless absolutely necessary. Local dependencies should be preferred.**

## Install

```sh
npm install import-global
```

## Usage

```sh
npm install --global cat-names
```

```js
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()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import).

## Related

- [resolve-global](https://github.com/sindresorhus/resolve-global) - Resolve the path of a globally installed module
- [import-from](https://github.com/sindresorhus/import-from) - Import a module from a given path
- [resolve-from](https://github.com/sindresorhus/resolve-from) - Resolve the path of a module from a given path
- [is-installed-globally](https://github.com/sindresorhus/is-installed-globally) - Check if your package was installed globally
- [global-directory](https://github.com/sindresorhus/global-directory) - Get the directory of globally installed packages and binaries

---
_Source: https://npm.io/package/import-global · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
