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

ModuleNotFoundError: Could not find module in path: '<path/file>' relative to '<path/file>' #6172

Open
fpasquet opened this issue Sep 30, 2021 · 6 comments

Comments

@fpasquet
Copy link

fpasquet commented Sep 30, 2021

Description of the problem

import { renderHook, act } from "@testing-library/react-hooks";

causes error:

ModuleNotFoundError: Could not find module in path: '@testing-library/react-hooks/lib/dom/pure' relative to '/node_modules/@testing-library/react-hooks/lib/pure.js'

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

Prevents application from loading in codesandbox so that React Test Library support cannot help with an issue I have with testing.

Link to sandbox: link (optional)

@fpasquet fpasquet reopened this Sep 30, 2021
@jsjoeio
Copy link

jsjoeio commented Jan 31, 2022

Did you ever figure this out? I'm running into this now with one of my own modules.

@CodeSandboxTeam
Copy link

CodeSandboxTeam commented Feb 1, 2022 via email

@jsjoeio
Copy link

jsjoeio commented Feb 1, 2022

@CodeSandboxTeam super cool y'all have a Team GH account.

Sorry for the noise. Turns out it was a user error. I was publishing the wrong files in my module 😅

@CodeSandboxTeam
Copy link

CodeSandboxTeam commented Feb 1, 2022 via email

@pksjce
Copy link

pksjce commented Feb 14, 2022

Hi, I have this same error in https://codesandbox.io/s/ancient-rgb-70b30 with the latest @primer/react version. This is specifically after a change that introduced subpath exports.
The library version works fine on stackblitz and on webpack powered builds in create-react-app and nextjs. I get the following error on codesandbox

ModuleNotFoundError: Could not find module in path: '@primer/react/lib-esm/Button' relative to '/node_modules/@primer/react/lib-esm/Dialog/Dialog.js'

image

In the above error the relative path ../Button inside /node_modules/@primer/react/lib-esm/Dialog/Dialog.js. During resolution, it becomes @primer/react/lib-esm/Button when expected path should be node_modules/@primer/react/lib-esm/Button/index.js.
Do you think it may have something to do with the new resolver changes introduced in #6148 ?

Here is the issue tracked in @primer/react primer/react#1863

@JamesACS
Copy link
Contributor

JamesACS commented Mar 3, 2022

Thanks @pksjce - I definitely agree that it looks like an issue with the new resolver changes. I've flagged this on our end!

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

5 participants