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

ERR_UNSUPPORTED_ESM_URL_SCHEME error on Windows 10 #35

Closed
Coteh opened this issue Jun 4, 2021 · 4 comments
Closed

ERR_UNSUPPORTED_ESM_URL_SCHEME error on Windows 10 #35

Coteh opened this issue Jun 4, 2021 · 4 comments

Comments

@Coteh
Copy link

Coteh commented Jun 4, 2021

Platform: Windows 10, 64 bit
Node: v14.17.0
NPM: 6.14.13
ospec: 4.1.1

Reproduction Steps

  1. npm install --save-dev ospec
  2. Change test command in package.json to ospec
  3. Add tests/mytest.spec.js with following:
const o = require('ospec');
const assert = require('assert');

o.spec("my test", () => {
    o("things are working", () => {
        assert.strictEqual("foo", "bar");
    });
});

Expected

Just a message saying 0 assertions passed

Actual

0 assertions passed, with 1 assertion bailed out with following: (note: I altered the name of the project directory in output)

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:782: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/cjs/loader.js:1011:27)
    at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:30:14)
    at eval (eval at <anonymous> (C:\Users\JamesCote\Projects\my-project\node_modules\ospec\bin\ospec:24:15), <anonymous>:1:1)
    at C:\Users\JamesCote\Projects\my-project\node_modules\ospec\bin\ospec:24:15
    at C:\Users\JamesCote\Projects\my-project\node_modules\ospec\bin\ospec:75:15
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}

C:\Users\JamesCote\Projects\my-project\tests\mytest.spec.js > > > BAILED OUT < < <:
Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
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:782: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/cjs/loader.js:1011:27)
    at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:30:14)
    at eval (eval at <anonymous> (C:\Users\JamesCote\Projects\my-project\node_modules\ospec\bin\ospec:24:15), <anonymous>:1:1)
    at C:\Users\JamesCote\Projects\my-project\node_modules\ospec\bin\ospec:24:15
    at C:\Users\JamesCote\Projects\my-project\node_modules\ospec\bin\ospec:75:15
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

––––––
The 0 assertion passed (old style total: 1). Bailed out 1 time
npm ERR! Test failed.  See above for more details.

A possible workaround is to downgrade Node.js to v10.15.2, but perhaps this should be investigated to allow for support on newer versions as well.

@gilbert
Copy link
Contributor

gilbert commented Jun 4, 2021

Does your package.json have "type": "module" in it?

@Coteh
Copy link
Author

Coteh commented Jun 4, 2021

It does not, no. And if I put that in, same error occurs.

@dead-claudia
Copy link
Member

Will be fixed by #30 once @pygy revisits it. (I just don't have the time ATM.)

@pygy
Copy link
Member

pygy commented May 17, 2022

At long last this is fixed. Sorry for the delay

@pygy pygy closed this as completed May 17, 2022
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

No branches or pull requests

4 participants