-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Open
Labels
needs triageThis issue has not been looked intoThis issue has not been looked into
Description
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
The FileTypeValidator runs into (and catches) an exception when trying to load file-type under Windows. This is because require.resolve("file-type") returns an absolute (Windows) path, which one must not plug into loadEsm (see e.g. nodejs/node#31710).
Minimum reproduction code
https://github.com/schulzjo-tng/file-type-windows-issue-repro
Steps to reproduce
- On Windows, run
npm iandnpm startin the linked repository.
If you do not have a Windows machine, take a look at this CI run:
Run npm start
> [email protected] start
> node index.cjs
node:internal/modules/esm/load:195
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(parsed, schemes);
^
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:195:11)
at defaultLoadSync (node:internal/modules/esm/load:142:3)
at #loadAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:795:12)
at #loadSync (node:internal/modules/esm/loader:815:49)
at ModuleLoader.load (node:internal/modules/esm/loader:780:26)
at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:526:31)
at #getOrCreateModuleJobAfterResolve (node:internal/modules/esm/loader:571:36)
at afterResolve (node:internal/modules/esm/loader:624:52)
at ModuleLoader.getOrCreateModuleJob (node:internal/modules/esm/loader:630:12)
at onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:649:32) {
code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}
Node.js v24.12.0
Error: Process completed with exit code 1.
Expected behavior
The file-type package should be loaded correctly on Windows.
NestJS version
11.1.11
Packages versions
Only @nestjs/common is relevant, which is on version 11.1.11.
Node.js version
24.11.1
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
This is a regression from #16077.
Metadata
Metadata
Assignees
Labels
needs triageThis issue has not been looked intoThis issue has not been looked into