fix(common): regression in loading file-type under Windows OS#16187
Merged
kamilmysliwiec merged 4 commits intoJan 15, 2026
Conversation
This adds GitHub Actions workflow to test on Ubuntu, Windows, and macOS. This is optional and can be removed if the maintainers prefer. Related to nestjs#16179
Uses pathToFileURL to convert file system paths to proper URLs before passing to the ESM loader, ensuring cross-platform compatibility. Fixes nestjs#16179
Pull Request Test Coverage Report for Build 03b1f073-5d58-402b-8343-1f264a8368eaDetails
💛 - Coveralls |
Member
|
lgtm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #16179
Error Message
On Windows OS,
FileTypeValidatorfails when dynamically loading thefile-typeESM package with the following error:Causes
Window OS Absolute Paths: (e.g.,D:\Users\Project\node_modules\file-type\index.js)load-esmpackage) interprets the drive letter(e.g.,D:) as an invalid URL Scheme instead of recognizing it as a file path.file-typepackage migrated to ESM-only.What is the new behavior?
Windows absolute paths are now converted to proper
file://URLs using Node.js's built-inpathToFileURL()function before being passed toloadEsm().This ensures cross-platform ESM compatibility:
D:\path\to\file-type→file:///D:/path/to/file-type/path/to/file-type→file:///path/to/file-typeDoes this PR introduce a breaking change?
Other information
Testing
FileTypeValidatortests pass on Ubuntu, macOS, and Windowsurl.pathToFileURL()Technical Details
file://URLs on all platformspathToFileURL()is available in all supported Node.js versionsNote