Skip to content

hotfix/shixiang/new_version_nodejs#51

Merged
tangshixiang merged 1 commit intomainfrom
hotfix/shixiang/new_version_nodejs
Mar 31, 2026
Merged

hotfix/shixiang/new_version_nodejs#51
tangshixiang merged 1 commit intomainfrom
hotfix/shixiang/new_version_nodejs

Conversation

@tangshixiang
Copy link
Copy Markdown
Collaborator

Summary

Fix npm install failure caused by the native canvas package requiring system-level C++ libraries (Cairo, Pango, etc.) that may not be present on all machines. Make canvas optional with a graceful runtime fallback.

Changes

Move canvas from dependencies to optionalDependencies in package.json so npm install no longer fails when native build tools are missing
Refactor pdf-image-extractor.ts to use lazy dynamic import("canvas") instead of a static import, with automatic fallback to text-only PDF extraction when canvas is unavailable
Export isCanvasAvailable() helper for callers that need to check canvas availability
Add "Optional: PDF Image Extraction (canvas)" section to README.md with system dependency install commands for macOS, Ubuntu/Debian, Fedora/RHEL, and Windows

Related Issues

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

Checklist

  • My code follows the project's coding style
  • I have added tests that cover my changes (if applicable)
  • All new and existing tests pass (npm test)
  • Lint passes (npm run lint)
  • I have updated the documentation (if applicable)
  • I have checked that there are no sensitive data (API keys, tokens, etc.) in my changes

@tangshixiang tangshixiang merged commit 6f12d57 into main Mar 31, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant