codesandbox / codesandbox-client

An online IDE for rapid web development
https://codesandbox.io
Other
13.04k stars 2.27k forks source link

Could not find module in path: 'readable-stream/errors' relative to '/node_modules/readable-stream/lib/internal/streams/state.js' #4957

Closed harryEth closed 4 years ago

harryEth commented 4 years ago

🐛 bug report

Preflight Checklist

Description of the problem

Could not find module in path: 'readable-stream/errors' relative to '/node_modules/readable-stream/lib/internal/streams/state.js'

image

This error happens on 2 of my projects. This package should be a node js native package. All projects works well on the local and built production environment. Just not working on the codesandbox.

Does anyone know how to fix this?

How has this issue affected you? What are you trying to accomplish?

my project is blocked by this error.

To Reproduce

Just go to the link below, it shows directly.

Link to sandbox: [link]() (optional)

https://codesandbox.io/s/github/MagicLabs/example-avalanche

Your Environment

Software Name/Version
Сodesandbox
Browser Chrome Version 85.0.4183.102 (Official Build) (64-bit)
Operating System Mac OS Catalina version 10.15.3 (19D76)
siddharthkp commented 4 years ago

Hi Harry, I'm not aware of avalanche, so i'm not fully sure what's going on. But it seems to be a missing link between the packages stream-browserify and readable-stream

When I add stream-browserify as an explicit dependency to the sandbox, it works, here's the sandbox: https://codesandbox.io/s/repro-4957-qvpzw

I'm inclined to believe that this is an issue with the package itself, and not CodeSandbox but I could be wrong.

Let me know if the above sandbox helps and feel free to reach out to me if you have more context into the issue.

CompuIves commented 4 years ago

I went down a rabbit hole on this one. It turns out that for dependencies that specify two different versions for the same dependency we don't handle moving correctly. So in this scenario:

- a
  - b
    - c@1.0.0
  - d
    - c@2.0.0

We wouldn't include both versions of c, just the first version that we found. Which led to this bug. We always did handle it correctly for these cases:

- a
  - b
    - c@1.0.0
- f
  - d
    - c@2.0.0

But not for the case where they originate from a single root dependency. It should now be fixed though! The packager that handles this has been updated and for new dependencies everything should work as expected. It unfortunately only works for new packages though, due to our cache.

The solution of @siddharthkp works well, because with that change we actually end up in case 2, which we already work well with.

siddharthkp commented 4 years ago

We have a fix ✨ I tested the sandbox from your description, it's works

Thanks again for reporting this, it helped us find sneaky issues in our bundler.

If you run into any other issues, feel free to reach out to us. Thanks!

NickCarducci commented 3 years ago

mine is 'util/util.js' relative to '/node_modules/readable-stream/3.6.0/lib/_stream_readable.js'; tried manipulating the start script to rm -rf node_modules && rm -rf .cache because this refers to an internal environment package, but no luck yet. Forking and different devices, produces the same. It was working ok last night.

Edit: now it works. I swear, there is a morning-timeout .cache that I have too many other projects to look at your source code instead of shelve my use case, maybe I should have restarted my computer, it could be my experiments with @arcgis dependency call

JamesACS commented 2 years ago

hEY @NickCarducci - I'm not seeing any problems on that Sandbox - has the issue been resolved now?

NickCarducci commented 2 years ago

Yes @JamesACS , I put the edit last, appended, "now it works." But on Sept 17 I recall now my case is one of many potential with this error message and process, yet my issue is certainly trying @arcgis either the way I did or at all, to which I am shelving in my product maps for now. I am just experimenting with v8 without node, and the transpiled-javascript, so I really have no idea this general error yet, or even why @arcgis could have possibly done that