# Is phantomjs-prebuilt ESM-only? Can you require() it?

> phantomjs-prebuilt@2.1.16 is a CommonJS package. CommonJS — require() works on every Node.js version we test.

Headless WebKit with JS API

Latest version 2.1.16, published Nov 2, 2017.

phantomjs-prebuilt ships CommonJS only. require("phantomjs-prebuilt") should work on every Node.js version the package supports; the runtime probe has not run for this version. import "phantomjs-prebuilt" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

**Deprecated:** this package is now deprecated

## What to do

1. require("phantomjs-prebuilt") should work on every Node.js version the package supports; the runtime probe has not run for this version.
2. From ES modules use the default import: import phantomjsPrebuilt from "phantomjs-prebuilt"; then destructure. Named imports only work when Node.js can statically detect the exports.
3. TypeScript: no types are available for phantomjs-prebuilt; declare the module yourself if you need them.
4. This package is deprecated: this package is now deprecated

## Facts

- Latest: 2.1.16 (Nov 2, 2017)
- Module format: CommonJS
- Last CommonJS version: 2.1.16
- TypeScript types: none
- Node engines: not declared
- Weekly downloads: 391K
- License: Apache-2.0

## Runtime test results for phantomjs-prebuilt@2.1.16

Runtime probe pending for this version (install failed: error: install script from "phantomjs-prebuilt" exited with 1). The facts above come from package.json.

## How to import phantomjs-prebuilt

ES modules:

```js
import phantomjsPrebuilt from "phantomjs-prebuilt";
```

CommonJS:

```js
const phantomjsPrebuilt = require("phantomjs-prebuilt");
```

## Module format by version

Derived from the type, main and exports fields of every stable release on npm (15 versions; the newest 15 shown).

| Versions | Format | First published |
|---|---|---|
| 2.1.2 – 2.1.16 | CommonJS | Jan 27, 2016 |

## Frequently asked

**Is phantomjs-prebuilt ESM-only?**

phantomjs-prebuilt@2.1.16 is a CommonJS package. phantomjs-prebuilt ships CommonJS only. require("phantomjs-prebuilt") should work on every Node.js version the package supports; the runtime probe has not run for this version. import "phantomjs-prebuilt" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

**Can I import phantomjs-prebuilt with ES module syntax?**

Yes. import phantomjsPrebuilt from "phantomjs-prebuilt" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.

**Does phantomjs-prebuilt ship TypeScript types?**

No. phantomjs-prebuilt ships no type declarations and there is no @types package for it.

## Links

- [phantomjs-prebuilt on npm](https://www.npmjs.com/package/phantomjs-prebuilt)
- [Source repository](https://github.com/Medium/phantomjs)
- [HTML version](https://canirequire.com/package/phantomjs-prebuilt/)
- [JSON version](https://canirequire.com/package/phantomjs-prebuilt.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
