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

error: Uncaught (in promise) TypeError: Unsupported scheme "node" for module "node:XXX" #16223

Closed
Kycermann opened this issue Oct 9, 2022 · 12 comments · Fixed by #17264
Closed
Assignees
Labels
bug Something isn't working correctly node compat

Comments

@Kycermann
Copy link

Kycermann commented Oct 9, 2022

Single step to reproduce

Run this command (revised command courtesy of AnInternetTroll):

deno eval --unstable 'import "npm:assemblyscript/asc"'

Error output:

error: Uncaught (in promise) TypeError: Unsupported scheme "node" for module "node:module". Supported schemes: [
    "data",
    "blob",
    "file",
    "http",
    "https",
]
    at async file:///home/codespace/.cache/deno/npm/registry.npmjs.org/assemblyscript/0.21.6/dist/asc.js:7:6221

This is because the module in question does import 'module' which I believe Deno translates to import 'node:module' ("module" being an actual Node module- confusing haha).

I've tried this in Github Codespaces (deno 1.26.1+a622c5d (canary, x86_64-unknown-linux-gnu))

@AnInternetTroll
Copy link
Contributor

Same error on linux 5.15.59 and deno 1.26.1+a622c5d

@bartlomieju bartlomieju self-assigned this Oct 11, 2022
@bartlomieju bartlomieju added bug Something isn't working correctly node compat labels Oct 11, 2022
@kedicesur
Copy link

I met this error with the deno test command while working on an AssemblyScript project. Obviously I had forgotten the --allow-read flag. Have you tried?

 deno eval --unstable --allow-read 'import "npm:assemblyscript/asc"'

@AnInternetTroll
Copy link
Contributor

deno eval doesn't accept any --allow-* flags.
And if you put import "npm:assemblyscript/asc" in a file and run the file with deno run --allow-read --unstable then you should get the same error. At least I do on 1.28.1

@dotandimet
Copy link

Hi, I'm seeing the same sort of error messages when trying out deno's npm support (specifically, I'm trying to see how well it can do running mojo.js). The npm packages get parsed, but it chokes on imports with the node: specifier.

Even something as simple as this:

import { Stream } from 'node:stream';

Causes deno run to throw the Unsupported scheme error

error: Unsupported scheme "node" for module "node:stream". Supported schemes: [
    "data",
    "blob",
    "file",
    "http",
    "https",
]
    at file....

The node: prefix is explicit in the file, not added while processing an npm package. I think deno should always try to handle that by loading its node API compatibility layer and not let it fall through to the module loader.

@bartlomieju
Copy link
Member

@dotandimet could you please provide a minimal reproduction to that error you're getting?

@Kycermann
Copy link
Author

@dotandimet could you please provide a minimal reproduction to that error you're getting?

Steps to reproduce

  • Run deno upgrade
  • Run deno
  • Paste import { Stream } from 'node:stream';

Output

Deno 1.28.1
exit using ctrl+d, ctrl+c, or close()
> import { Stream } from 'node:stream';
Uncaught TypeError: Unsupported scheme "node" for module "node:stream". Supported schemes: [
    "data",
    "blob",
    "file",
    "http",
    "https",
]
    at async <anonymous>:2:21

@JonathonRP
Copy link

JonathonRP commented Dec 8, 2022

@bartlomieju, I am getting this error using vite and demo with --node-modules-dir flag. I am attempting to use vite with vite.config.mts and it seems this has broken vite support.

@bartlomieju
Copy link
Member

@JonathonRP can you share your project with commands to run it? This is still on our radar, but is blocked by #16748.

@JonathonRP
Copy link

@bartlomieju, https://github.com/JonathonRP/JonathonRP.github.io/tree/Feature/SvelteKit.
Please use codespaces and run the command - 'deno task dev' in the terminal of codespace.

  • let me know if you can't use codespace; I haven't done this before.

@Kycermann
Copy link
Author

Can confirm this bug is still in Deno 1.29- by running deno eval --unstable 'import "npm:assemblyscript/asc"'

@JonathonRP
Copy link

@bartlomieju, this is still a problem please check the repo I provided and let me know. This is a big blocker for me to use deno with vite

@bartlomieju
Copy link
Member

@bartlomieju, this is still a problem please check the repo I provided and let me know. This is a big blocker for me to use deno with vite

As pointed before, this is blocked by #16748. Without I'm not sure we can support it. I might take a stab it after New Year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants