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

v7.4.0 breaks on ESM modules with imports of builtin modules #281

Closed
lehni opened this issue Mar 27, 2022 · 4 comments · Fixed by #282
Closed

v7.4.0 breaks on ESM modules with imports of builtin modules #281

lehni opened this issue Mar 27, 2022 · 4 comments · Fixed by #282

Comments

@lehni
Copy link
Contributor

lehni commented Mar 27, 2022

Sample code:

package.json

{
  "name": "node-dev-crash",
  "main": "index.js",
  "type": "module",
  "dependencies": {
    "node-dev": "^7.4.0"
  },
  "scripts": {
    "start": "node-dev index.js"
  }
}

index.js

import path from 'path';

console.log(path.resolve());

Run:

npm install
npm run start

Error:

$ node-dev index.js
TypeError [ERR_INVALID_URL_SCHEME]: The URL must be of scheme file
    at new NodeError (internal/errors.js:322:7)
    at fileURLToPath (internal/url.js:1372:11)
    at getFormat (file:///.../node-dev-crash/node_modules/node-dev/lib/loaders/get-format.mjs:8:20)
    at Loader.getFormat (internal/modules/esm/loader.js:105:42)
    at Loader.getModuleJob (internal/modules/esm/loader.js:243:31)
    at async ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:78:21)
    at async Promise.all (index 0)
    at async link (internal/modules/esm/module_job.js:83:9)
@bjornstar
Copy link
Collaborator

Which version of node are you using? get-format loader looks like something <16.12.

@bjornstar
Copy link
Collaborator

seems to have the same problem with the load loader as well in 16.14

@lehni
Copy link
Contributor Author

lehni commented Mar 27, 2022

I've tested v14.19.1 and v16.14.2, both have exhibited this behaviour.

@lehni
Copy link
Contributor Author

lehni commented Mar 27, 2022

Hmm I'm still seeing problems with v7.4.1:

Error: The worker thread exited
    at Worker.onWorkerExit (/.../node_modules/thread-stream/index.js:180:32)
    at Worker.emit (node:events:526:28)
    at Worker.emit (node:domain:475:12)
    at Worker.[kOnExit] (node:internal/worker:278:10)
    at Worker.<computed>.onexit (node:internal/worker:198:20)
TypeError: Path must be a string.
    at resolveSync (/Users/lehni/Development/Lineto/lineto/node_modules/node-dev/node_modules/resolve/lib/sync.js:75:15)
    at module.exports (/Users/lehni/Development/Lineto/lineto/node_modules/node-dev/lib/resolve-main.js:6:10)
    at getConfig (/Users/lehni/Development/Lineto/lineto/node_modules/node-dev/lib/cfg.js:33:16)
    at Object.<anonymous> (/Users/lehni/Development/Lineto/lineto/node_modules/node-dev/lib/wrap.js:12:34)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at Module._preloadModules (node:internal/modules/cjs/loader:1280:12)
[ERROR] 23:01:49 Error: The worker thread exited
[ERROR] 23:01:49 TypeError: Path must be a string.

I'll investigate tomorrow.

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