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

Failing to install npm dependencies when using self-hosted bundlerURL #37

Open
1 of 2 tasks
zaini opened this issue Oct 6, 2022 · 8 comments
Open
1 of 2 tasks
Labels
bug Something isn't working

Comments

@zaini
Copy link

zaini commented Oct 6, 2022

Bug report

Packages affected

  • sandpack-client
  • sandpack-react

Description of the problem

I have this sandpack-bundler running: https://github.com/codesandbox/sandpack-bundler

In the example sandbox below, you will see I am setting the bundlerURL in the SandboxProvider.

The sandpack created doesn't actually work though due to failing to properly important the library. It works fine when I don't set bundlerURL and use the default bundler. Example of the error:

image

(Sometimes the error is about failing to import other stuff like Cannot find module 'process' from '/node_modules/vfile/lib/minproc.js')

It works fine when I try other libraries like "uuid: latest", but testing with "react-markdown: latest" has given me these errors. I've tried a couple other libraries and had issues with them too. It's like it's not doing npm install properly.

Again I should note that if I don't define bundlerURL and use the default, it works fine.

(Side note: sandpack-client and sandpack-react seem to use a different bundler version, 1.7.0 vs 1.8.8)

Link to sandbox: link

Your Environment

Software Name/Version
Sandpack-client version
Sandpack-react version 1.0.0 and also tried 1.8.8
Browser Chrome
Operating System MacOS
@zaini zaini added the bug Something isn't working label Oct 6, 2022
@danilowoz danilowoz transferred this issue from codesandbox/sandpack Oct 6, 2022
@danilowoz
Copy link
Member

@DeMoorJasper could you please take a look at this issue?

@zaini
Copy link
Author

zaini commented Oct 13, 2022

Any updates on this? I tried it on another PC and still get the same errors. It's a bit odd since some libraries work with the locally hosted bundler whereas others don't.

And all libraries work fine when using the CDN bundler. So it's almost like the locally hosted bundler is not the same as the CDN one.

Is there another bundler that can be used in the same way and is compatible with Sandpack?

@DeMoorJasper
Copy link
Member

It should be identical to using: https://sandpack-bundler.pages.dev/ as bundlerUrl. You're probably comparing it to the v1 bundler which is still the default for sandpack, for which the sourcecode is here: https://github.com/codesandbox/codesandbox-client

@zaini
Copy link
Author

zaini commented Oct 13, 2022

If I change the bundlerUrl from my locally hosted bundler (https://github.com/codesandbox/sandpack-bundler), to https://sandpack-bundler.pages.dev/ I still get the same error. The only thing that works is not defining bundlerUrl so that it uses the default CDN bundler (which I don't want to use.)

image

@DeMoorJasper
Copy link
Member

Yes, that's what I suspected, it's a bug in the new v2 bundler, you should probably follow this guide instead for self-hosting the v1 bundler: https://sandpack.codesandbox.io/docs/advanced-usage/client#hosting-the-bundler

@zaini
Copy link
Author

zaini commented Oct 16, 2022

How do I host the www file? I'm trying just npx http-server and then passing http://127.0.0.1:8080/ as the bundlerUrl but that doesn't seem to work.

Ideally I'm looking to only host the bundler. Is the bug with sandpack-bundler being tracked?

Thanks.

@KevinEdry
Copy link

Hey @DeMoorJasper, is this still an issue? I assume it is fixed by now.

@DeMoorJasper
Copy link
Member

Don't think we've fixed this on the new experimental bundler, but it works on the stable bundler.

We're not yet sure how we're gonna fix this yet.

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

No branches or pull requests

4 participants