initialize() of express-openapi 12.0.0 always throws exception on Windows
See original GitHub issueAfter the update to express-openapi 12.0.0 my CommonJS app crashes on Windows when I’m calling the initialize
method from the express-openapi
package:
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
at new NodeError (node:internal/errors:372:5)
at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1120:11)
at defaultResolve (node:internal/modules/esm/resolve:1200:3)
at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
at ESMLoader.import (node:internal/modules/esm/loader:380:22)
at importModuleDynamically (node:internal/modules/cjs/loader:1043:29)
at importModuleDynamicallyWrapper (node:internal/vm/module:437:21)
at importModuleDynamically (node:vm:381:46)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
For Windows, the issue can be solved by changing in openapi-framework/index.ts, line 238
from
const imported = await import(fsRoutesItem.path);
to
const imported = await import(`file:///${fsRoutesItem.path}`);
Of course, this is just a first dirty hack and not tested on other platforms than Windows. Can someone check this and provide a fixed version 12.0.1, please?
Issue Analytics
- State:
- Created a year ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
express-openapi - npm
initialize (args). Initializes paths and middleware on an express app, and returns an initialized api. An initialized api contains the following ...
Read more >How to use the express-openapi.initialize function in ... - Snyk
To help you get started, we've selected a few express-openapi.initialize examples, based on popular ways it is used in public projects.
Read more >Bad error message if operationId is not specified #465 - GitHub
When calling initialize with an apiDoc that has an operation that is missing an operationId, express-openapi emits a warning and then throws ......
Read more >Could not load file or assembly 'Newtonsoft.Json, Version=9.0 ...
But when I run the application and call a Native method in Windows Runtime Component it gives some kind of strange errors as:...
Read more >netlify-cli | Yarn - Package Manager
Generate a handler for a Graph operation given its name. See graph:operations for a list of operations. graph:init, Initialize all the resources for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Haven’t tested the change on Windows yet … The CommonJS script / ES module loader of Node.js seems to require some special treatment for Windows.
Will try on Windows tomorrow.
Thanks! It works on Windows again.