canirequire

canirequire › CommonJS › phantomjs-prebuilt

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

Headless WebKit with JS API

Latest version 2.1.16, published Nov 2, 2017. Markdown · JSON

CommonJS CommonJS — require() works on every Node.js version we test

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.

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
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

Deprecated: this package is now deprecated

Does phantomjs-prebuilt@2.1.16 actually load? Runtime test results

Runtime probe pending for this version. The values below are what package.json declares; they are refreshed once the probe runs.

Runtimerequire("phantomjs-prebuilt")import "phantomjs-prebuilt"
Node.js 18✓ expected✓ expected
Node.js 20✓ expected✓ expected
Node.js 22✓ expected✓ expected
Node.js 24✓ expected✓ expected
Node.js 26✓ expected✓ expected
Bun 1.4.0pendingpending

Install failed in our sandbox: error: install script from "phantomjs-prebuilt" exited with 1 The rows above show what package.json declares.

How to import phantomjs-prebuilt

ES modules (import)

import phantomjsPrebuilt from "phantomjs-prebuilt";

Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.

CommonJS (require)

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

Module format by version

Derived from the type, main and exports fields of every stable release on npm, corrected where a runtime test of that version contradicted them (15 versions; the newest 15 shown).

VersionsFormatFirst published
2.1.2 – 2.1.16CommonJSJan 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

Other commonjs packages

Similar popularity