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

Support dependencies with node_modules folders in them #4456

Open
tay1orjones opened this issue Jun 23, 2020 · 19 comments
Open

Support dependencies with node_modules folders in them #4456

tay1orjones opened this issue Jun 23, 2020 · 19 comments
Assignees
Labels
🎒 Bundler Refers to CodeSandbox's In-Browser Bundler

Comments

@tay1orjones
Copy link

tay1orjones commented Jun 23, 2020

🐛 bug report

Description of the problem

I receive the error

ModuleNotFoundError
Could not find module in path: 'carbon-addons-iot-react/es/node_modules/carbon-components-react/es/prop-types/types.js' relative to '/node_modules/carbon-addons-iot-react/es/src/components/Button/Button.jsx'

Despite this being available at the location indicated.

Here's a screencap of our build output for carbon-addons-iot-react

Additionally you can see the file is available at this location in our package in unpkg
https://unpkg.com/carbon-addons-iot-react@2.93.5/es/node_modules/carbon-components-react/es/prop-types/types.js

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

This prevents us from using codesandbox as a bug reporting and example code tool.

Link to sandbox: https://codesandbox.io/s/objective-darkness-r8xzc?file=/src/index.js

Your Environment

Software Name/Version
Сodesandbox 015cbaa (this was in the bottom left corner of the page)
Browser Chrome
Operating System MacOS
@tay1orjones
Copy link
Author

@cowills @mhewson should #709 have fixed this? The error is still present in the linked sandbox above.

@cowills
Copy link

cowills commented Jul 7, 2020

@cowills @mhewson should #709 have fixed this? The error is still present in the linked sandbox above.

Nope, we just fixed the issue in our codebase by switching to a different bundle of our library.

@tay1orjones
Copy link
Author

Ah! My mistake - I didn't realize the PR was in your codebase and not in codesandbox 🤦

@CompuIves
Copy link
Member

Oh yes, this is interesting. The fact that it includes /node_modules confuses the bundler I think, and makes it look on unpkg to find whether the file exists... Doing a deeper dive now.

@CompuIves
Copy link
Member

Yes, that's the case. The challenge here is that the in-browser bundler has an incomplete view on all files that are available, and because of this it has to make some assumptions when it can't find a file. If there's a file missing in node_modules, it tries to resolve a package.json and resolve the appropriate file from unpkg. I think that's where this goes wrong, because in this case it can't find the right version on unpkg.

@CompuIves
Copy link
Member

The best solution would be to start saving paths for dependencies, as this would remove the whole guessing part. It would require us to regenerate the dependency cache for this, but other than that it seems like a sensible choice to me,

@github-actions
Copy link

github-actions bot commented Oct 8, 2020

This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.

@github-actions github-actions bot added the stale label Oct 8, 2020
@CompuIves
Copy link
Member

Keeping this one open since the saving paths feature is still something that's in the planning.

@CompuIves CompuIves removed the stale label Oct 12, 2020
@github-actions
Copy link

This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.

@github-actions github-actions bot added the stale label Jan 11, 2021
@github-actions
Copy link

This issue has been automatically closed because there wasn't any activity after the previous notice or the stale label wasn't removed.

@apsamuel
Copy link

This is still an issue

@CompuIves
Copy link
Member

Will reopen this one, and also rename the title a bit because we've narrowed the scope on this one. For what sandbox do you have this issue @apsamuel ?

@CompuIves CompuIves reopened this Feb 2, 2021
@CompuIves CompuIves changed the title ModuleNotFoundError Could not find module in path Support dependencies with node_modules folders in them Feb 2, 2021
@github-actions github-actions bot removed the stale label Feb 3, 2021
@apsamuel
Copy link

Will reopen this one, and also rename the title a bit because we've narrowed the scope on this one. For what sandbox do you have this issue @apsamuel ?

apologies for the delay - https://codesandbox.io/s/dme0w, I emailed out to codesandbox team and was informed there may have been an infrastructure issue on that specific occasion

@github-actions
Copy link

This issue has automatically been marked stale because there has been no activity in a while. Please leave a comment if the issue has not been resolved, or if it is not stale for any other reason. After 2 weeks, this issue will automatically be closed, unless a comment is made or the stale label is removed.

@github-actions github-actions bot added the stale label May 15, 2021
@CompuIves CompuIves removed the stale label May 19, 2021
@shaoster
Copy link

shaoster commented May 21, 2021

Willing to take any PRs for this? Looks like anything that transitively depends on socket.io hits this now: https://github.com/socketio/engine.io-client/blob/9eeed5e0c0a3a3598d27947dabc57b47ca3a8365/lib/transports/index.js#L1.

See the package.json inclusion of (4.0.0): https://codesandbox.io/s/boardgameio-tutorial-setup-zgrsc?from-embed=&file=/package.json:259-290.

@CompuIves
Copy link
Member

Interesting case, it looks like in the case you mentioned the require to XMLHTTPrequest is not in a node modules directory so it should work. But I should check closer, we can do that on Monday or Tuesday! cc @DeMoorJasper

@shaoster
Copy link

I think the ../.. prefix resolves to a node_modules rooted dir.

From the repro above:
image

@jsjoeio
Copy link

jsjoeio commented Oct 3, 2021

I'm running into this issue with this CodeSandbox

Seems like some other folks are experiencing this and opened an issue in socket-io-client

@CompuIves
Copy link
Member

Right, that should not happen. I'll make sure that we take a look at this this week and come with a solution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎒 Bundler Refers to CodeSandbox's In-Browser Bundler
Projects
None yet
Development

No branches or pull requests

8 participants