canirequire › CommonJS › phantomjs
Is phantomjs ESM-only? Can you require() it?
Headless WebKit with JS API
Latest version 2.1.7, published Apr 7, 2016. JSON
CommonJS CommonJS — require() works on every Node.js version
phantomjs ships CommonJS only. require("phantomjs") works everywhere. import "phantomjs" 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: Package renamed to phantomjs-prebuilt. Please update 'phantomjs' package references to 'phantomjs-prebuilt'
Does phantomjs@2.1.7 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.
| Runtime | require("phantomjs") | import "phantomjs" |
|---|---|---|
| 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 | pending | pending |
Install failed in our sandbox: error: install script from "phantomjs" exited with 1 The rows above show what package.json declares.
How to import phantomjs
ES modules (import)
import phantomjs from "phantomjs";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 phantomjs = require("phantomjs");Module format by version
Derived from the type, main and exports fields of every stable release on npm (34 versions; the newest 34 shown).
| Versions | Format | First published |
|---|---|---|
| 0.0.1 – 2.1.7 | CommonJS | Sep 10, 2012 |
Frequently asked
Is phantomjs ESM-only?
phantomjs@2.1.7 is a CommonJS package. phantomjs ships CommonJS only. require("phantomjs") works everywhere. import "phantomjs" 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 with ES module syntax?
Yes. import phantomjs from "phantomjs" 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 ship TypeScript types?
Not bundled. Install the community types with "npm install -D @types/phantomjs".
Links
Other commonjs packages
- debug 4.4.3CommonJS
- semver 7.8.5CommonJS
- ms 2.1.3CommonJS
- picomatch 4.0.7CommonJS
- ajv 8.20.0CommonJS
- source-map 0.8.0CommonJS
- react-is 19.2.8CommonJS
- readable-stream 4.7.0CommonJS
Similar popularity
- rollup-plugin-delete 3.0.2ESM-only
- babel-plugin-transform-vue-jsx 3.7.0CommonJS
- run-sequence 2.2.1CommonJS
- rollup-plugin-uglify 6.0.4CommonJS
- karma-chai 0.1.0CommonJS
- jshint-stylish 2.2.1CommonJS
- eslint-friendly-formatter 4.0.1CommonJS
- ember-export-application-global 2.0.1CommonJS