MithrilJS / ospec

Noiseless testing framework
MIT License
48 stars 13 forks source link

ERR_UNSUPPORTED_ESM_URL_SCHEME error on Windows 10 #35

Closed Coteh closed 2 years ago

Coteh commented 3 years ago

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 commented 3 years ago

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

Coteh commented 3 years ago

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

dead-claudia commented 3 years ago

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

pygy commented 2 years ago

At long last this is fixed. Sorry for the delay