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

As long as I import a node module it fails to work #4

Closed
qiulang opened this issue Aug 1, 2018 · 5 comments
Closed

As long as I import a node module it fails to work #4

qiulang opened this issue Aug 1, 2018 · 5 comments

Comments

@qiulang
Copy link

qiulang commented Aug 1, 2018

First of all, your article and example is very helpful. Thank you!

But as long as I import a node module, as any "real" project will do, it fails to work. For example I add

import debug from 'debug' to sum.js then I will get the error

Uncaught TypeError: Failed to resolve module specifier "debug". Relative references must start with either "/", "./", or "../".

Any idea how can I fix it ? The last resort of course will be using webpack to bundle them into a single file, but I was hoping if there is any easy solution without bundling.

@vitalets
Copy link
Owner

vitalets commented Aug 6, 2018

As web browser does not know anything about node module structure you should import it by full path, e.g.

import debug from './node_modules/debug/src/browser.js';

In the future package maps should help with it.

@vitalets vitalets closed this as completed Aug 6, 2018
@Seanmclem
Copy link

I have the same issue. using the full path doesn't fix the issue. I just get a 404 for the file now

@skinet92
Copy link

skinet92 commented Mar 2, 2020

solutions...???!!

@121Unicorns
Copy link

I have the same issue. Trying to import node-rsa

@71iq
Copy link

71iq commented Sep 18, 2022

I have the saem issue. Anyone solved it yet?

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

6 participants