Common Issues
This page covers the most common issues you might encounter when using repo2pdf and how to resolve them.Installation & Dependencies
I'm getting an error 'Failed to install [package-name]'. What should I do?
I'm getting an error 'Failed to install [package-name]'. What should I do?
-
First, verify you have Node.js and npm installed:
-
Make sure you’re using Node.js version 18.0.0 or higher:
-
Try installing the failing package manually:
-
If the issue persists, try clearing npm cache:
-
Check if you have permission issues (especially on Linux/Mac):
Error: This package is ESM only
Error: This package is ESM only
Repository Issues
Error: 'Please enter a valid GitHub repository URL'
Error: 'Please enter a valid GitHub repository URL'
https://github.com/BankkRoll/repo2pdfhttps://github.com/microsoft/typescript
github.com/username/repo(missing https://)https://github.com/username/repo.git(don’t include .git)https://github.com/username(missing repository name)
Error: Failed to clone repository
Error: Failed to clone repository
- Git is not installed on your system
- Repository is private and requires authentication
- Network connectivity issues
- Invalid repository URL
-
Check if git is installed:
If not installed, download from git-scm.com
-
For private repositories:
- First clone the repository manually:
- Then use repo2pdf with the local repository option:
- First clone the repository manually:
-
Check network connectivity:
-
Verify the repository exists:
- Open the URL in your browser
- Make sure the repository is public
Error: 'Please enter a valid directory path'
Error: 'Please enter a valid directory path'
-
Verify the path exists:
-
Use absolute paths instead of relative paths:
- Good:
/home/user/projects/my-repo - Bad:
../my-repo
- Good:
-
On Windows, use forward slashes or escaped backslashes:
- Good:
C:/Users/username/projects/my-repo - Good:
C:\\Users\\username\\projects\\my-repo - Bad:
C:\Users\username\projects\my-repo
- Good:
PDF Generation Issues
Generated PDF is empty or missing files
Generated PDF is empty or missing files
-
Check default exclusions:
repo2pdf automatically excludes:
- Binary files (images, videos, executables)
- Common build directories (
node_modules,dist,.git) - Package manager files
-
Review your
repo2pdf.ignorefile: If you have arepo2pdf.ignorefile, check if it’s too aggressive: - Check file types: Make sure the files you want to include are text-based. Binary files are encoded as base64.
- Look for processing messages: The CLI shows “Processing files… (X processed)” - if this number is low, files are being filtered.
PDF is too large or takes too long to generate
PDF is too large or takes too long to generate
-
Use the ignore configuration:
Create a
repo2pdf.ignorefile to exclude unnecessary directories: - Enable “Remove comments”: This reduces file size by stripping code comments.
- Enable “Remove empty lines”: This creates more compact output.
-
Use “One PDF per file”:
Generate separate PDFs instead of one large file:
- Easier to manage
- Faster generation
- Can process specific files individually
Syntax highlighting not working
Syntax highlighting not working
-
Unsupported language:
- highlight.js supports 180+ languages
- Check if your language is supported at highlightjs.org
- If unsupported, files will be rendered as plain text
-
Incorrect file extension:
- Syntax highlighting is based on file extension
- Rename files to use standard extensions:
.jsfor JavaScript.tsfor TypeScript.pyfor Python
-
“Add highlighting” not selected:
- Make sure you check “Add highlighting” in the features selection
-
Malformed code:
- If code has syntax errors, highlighting may fall back to plaintext
Code formatting looks wrong in PDF
Code formatting looks wrong in PDF
-
Tab vs. spaces:
- repo2pdf converts tabs to 4 spaces
- If your code uses different tab width, it may look misaligned
-
Use Prettier-compatible files:
- repo2pdf attempts to format code with Prettier before PDF generation
- Supported formats: JS, TS, CSS, HTML, JSON, Markdown, and more
-
Line breaks:
- repo2pdf normalizes line endings (CRLF → LF)
- This shouldn’t affect appearance but ensures consistency
-
Special characters:
- Some Unicode characters may not render correctly
- Consider using ASCII alternatives for documentation
Configuration Issues
How can I customize the styling of the generated PDF?
How can I customize the styling of the generated PDF?
-
Clone the repo2pdf repository:
-
Modify the styling in the source code:
Font size (
src/clone.tsaround line 232):Colors (src/syntax.ts):- Modify the color mappings for syntax highlighting
src/clone.ts):- PDFKit uses
PDFDocumentwith configurable margins
-
Build and run your modified version:
How can I modify the ignored files list?
How can I modify the ignored files list?
repo2pdf.ignore file in the root of your repository.File location:- Add build directories to speed up processing
- Exclude sensitive files like
.env - Use extensions to filter file types (e.g.,
[".test.js"]to exclude tests)
Feature-Specific Issues
How can I include line numbers in the generated PDF?
How can I include line numbers in the generated PDF?
- ☑ Add line numbers
- Left-aligned
- Automatically padded for alignment
- Reset for each file (when using “One PDF per file”)
How can I keep the cloned repository after generating the PDF?
How can I keep the cloned repository after generating the PDF?
Yes- Repository stays in./tempRepoNo- Repository is automatically deleted after PDF generation
How can I generate a PDF for a local repository?
How can I generate a PDF for a local repository?
-
Run repo2pdf:
-
When asked “Do you want to use a local repository?”, select:
Yes
-
Provide the full path to your repository:
- Faster (no cloning required)
- Works with private repositories
- No git installation required
- Can test configurations quickly
What types of files are supported for conversion to PDF?
What types of files are supported for conversion to PDF?
- JavaScript, TypeScript, JSX, TSX
- Python, Java, C, C++, C#, Go, Rust
- HTML, CSS, SCSS, LESS
- JSON, YAML, XML
- Markdown, Plain text
- Shell scripts, Dockerfile
- And 180+ other languages via highlight.js
- Images, videos, audio files are detected and encoded as base64
- Displayed in the PDF as base64 strings
- Generally not useful in PDF form (excluded by default)
- Common image formats (
.png,.jpg,.gif,.svg) - Archives (
.zip,.tar,.gz) - Executables (
.exe,.dll,.so) - Media files (
.mp4,.mp3)
Performance Issues
Processing is very slow
Processing is very slow
- Add more files to ignore list: Exclude test files, build artifacts, and dependencies
-
Disable comment removal:
The
strip-commentsoperation can be slow on large files -
Disable Prettier formatting:
Prettier formatting happens automatically but adds processing time
- To disable: modify source code in
src/clone.ts
- To disable: modify source code in
- Use “One PDF per file”: Can be faster as PDFs are written in parallel
- Use local repository: Eliminates git clone time
Getting Help
If your issue isn’t covered here:GitHub Issues
View Source
Error Reporting
When reporting an issue, please include:-
Environment information:
-
Operating system:
- macOS version
- Linux distribution
- Windows version
-
Command and options used:
- Were you using npx or local installation?
- What features did you select?
-
Error messages:
- Copy the complete error output
- Include any stack traces
-
Repository details:
- Is it public or private?
- Approximate size (number of files)
- What file types are in the repo?