Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config file resolution fails on Windows #18

Closed
thw0rted opened this issue Jul 15, 2021 · 4 comments · Fixed by #19
Closed

Config file resolution fails on Windows #18

thw0rted opened this issue Jul 15, 2021 · 4 comments · Fixed by #19

Comments

@thw0rted
Copy link
Contributor

I'm storing my config in lws.config.js, in my project root. Running npx lws results in a stackdump:

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:777:11)
    at Loader.resolve (internal/modules/esm/loader.js:88:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:241:28)
    at Loader.import (internal/modules/esm/loader.js:176:28)
    at importModuleDynamically (internal/modules/esm/translators.js:114:35)
    at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:30:14)
    at getStoredConfig (file:///C:/Workspace/my-project/node_modules/lws/lib/util.mjs:60:7)
    at LwsCli.getConfig (file:///C:/Workspace/my-project/node_modules/lws/lib/cli-app.mjs:137:32)
    at LwsCli.start (file:///C:/Workspace/my-project/node_modules/lws/lib/cli-app.mjs:26:33)
    at file:///C:/Workspace/my-project/node_modules/lws/bin/cli.mjs:5:5

The problem is that this dynamic import is getting the Windows-style literal path C:\Workspace\my-project\lws.config.js instead of a file URL. Since you already require a pretty modern Node, I think you can safely use pathToFileURL which should work correctly on any platform.

@75lb
Copy link
Member

75lb commented Jul 15, 2021

Fixed by your PR #19. Thanks!

Since you already require a pretty modern Node

Node versions prior to v14 are no longer active..

@thw0rted
Copy link
Contributor Author

Wow, that's fast turnaround 😄

Per the release schedule, Node 12 LTS is still in Maintenance and doesn't hit EOL until April of next year. Node 14 is only a year old -- venerable in the fast-moving world of JS, but a relative baby in terms of corporate IT. (I work with government, and a lot of the tech is, uh, not new.)

@75lb
Copy link
Member

75lb commented Jul 15, 2021

yeah, the big institutions are often the furthest behind.. I realise v12 is still maintained, the main reason i moved support to minimum v14 was because the codebase is now ECMAScript with a package.json that uses the exports feature.. v12 supports ESM but behind a flag (until recently I believe - i think the flag requirement was removed in v12.20, will need to check).. I also had an issue with the CommonJs build of lws failing in v12 (the build produced by rollup didn't support dynamic loads, required by plugin-loading features like --view and --stack)..

If you have any general feedback in the future, feel free to post in the discussions tab..

@75lb
Copy link
Member

75lb commented Aug 6, 2021

Was a good point about the slow-moving institutions, so support extended back to v12.20

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 a pull request may close this issue.

2 participants