# function-exec-sync

> Run a function in a node process

Latest version **2.2.0** (published 2026-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install function-exec-sync
pnpm add function-exec-sync
yarn add function-exec-sync
bun add function-exec-sync
```

## Health

**Score 70/100 (B)** — status: active.

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2026-09-15 |
| First published | 2022-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=0.8 |
| Dependencies | 8 |
| Unpacked size | 143.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kevin Malakoff |
| Maintainers | kmalakoff |
| Keywords | function, exec, sync, execPath, typescript |

## Links

- npm: https://www.npmjs.com/package/function-exec-sync
- Repository: https://github.com/function-exec-sync
- Homepage: https://github.com/function-exec-sync#README.md
- Issues: https://github.com/function-exec-sync/issues
- npm.io page: https://npm.io/package/function-exec-sync

## Dependencies (8)

- [os-shim](https://npm.io/package/os-shim.md) ^0.1.0
- [short-hash](https://npm.io/package/short-hash.md) ^1.0.0
- [randombytes](https://npm.io/package/randombytes.md) ^2.1.0
- [temp-suffix](https://npm.io/package/temp-suffix.md) ^1.0.10
- [async-compat](https://npm.io/package/async-compat.md) ^1.4.6
- [module-compat](https://npm.io/package/module-compat.md) ^0.1.0
- [mkdirp-classic](https://npm.io/package/mkdirp-classic.md) ^0.5.3
- [thread-sleep-compat](https://npm.io/package/thread-sleep-compat.md) ^1.1.6

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 2.2.0 (latest) — 2026-09-15
- 2.1.7 — 2026-09-15
- 2.1.6 — 2026-09-15
- 2.1.5 — 2026-09-12
- 2.1.4 — 2026-09-03
- 2.1.3 — 2026-08-31
- 2.1.2 — 2026-08-24
- 2.1.1 — 2026-05-26
- 2.1.0 — 2025-12-20
- 2.0.2 — 2025-12-19
- 2.0.1 — 2025-12-19
- 2.0.0 — 2025-12-19
- 1.5.6 — 2025-12-15
- 1.5.5 — 2025-12-12
- 1.5.4 — 2025-12-12
- … 83 more at https://npm.io/package/function-exec-sync/versions

## README

# function-exec-sync

Run an exported function in a Node.js process and return its value.

```sh
npm install function-exec-sync
```

Create `worker.cjs`:

```js
module.exports = function (name, count) {
  return Array(count + 1).join(name);
};
```

Call it from another CommonJS file:

```js
var path = require('path');
var call = require('function-exec-sync');

var result = call(path.join(__dirname, 'worker.cjs'), 'ha', 2);
console.log(result); // "haha"
```

Pass `execPath` in an options object to select a Node executable:

```js
var result = call({ execPath: '/path/to/node' }, path.join(__dirname, 'worker.cjs'), 'ha', 2);
```

The target module, arguments, and returned value cross a process boundary, so
keep them serializable by this package. Circular values are not supported.

### Documentation

[API Docs](https://kmalakoff.github.io/function-exec-sync/)

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