-
-
Notifications
You must be signed in to change notification settings - Fork 27
Description
Description:
The current implementation of the PNG export functionality relies on the svg2png package, which is built on top of phantomjs-prebuilt. As of 2017, PhantomJS has been officially deprecated and is no longer maintained.
The Problem:
Using phantomjs-prebuilt causes significant issues in modern development environments:
-
Package Manager Compatibility (pnpm): Modern package managers like pnpm block the execution of arbitrary build scripts for security reasons. Since phantomjs-prebuilt requires a post-install script to download its binary, it fails to install correctly, leading to TypeError [ERR_INVALID_ARG_TYPE] or MODULE_NOT_FOUND errors during execution.
-
Node.js Version Mismatch: The native binaries required by PhantomJS are increasingly incompatible with modern Node.js versions (v20+), causing silent failures or segmentation faults.
3.Maintenance Overhead: Because it relies on an outdated WebKit engine, it does not support modern CSS/SVG features, leading to rendering inconsistencies.
Steps to Reproduce (with pnpm):
1.Clone the repository.
2.Run pnpm install.
3.Attempt to generate a PNG: node bin/lts.js -s 2026-01-01 -e 2027-01-01 -p output.png.
4.Result: The process crashes because the PhantomJS binary is missing or the build script was ignored.
Suggested Solution:
I recommend replacing svg2png with a modern, high-performance alternative that does not rely on a headless browser or complex post-install scripts.
Top candidates:
-
@resvg/resvg-js: Extremely fast, Rust-based, and highly compliant with SVG standards.
-
sharp: The industry standard for Node.js image processing.
Environment:
-
Node.js version: v24.x (and other modern LTS versions)
-
**Package Manager **: pnpm / npm
-
**OS **: Windows / Linux / macOS