Skip to content

ModuleNotFoundError: Could not find module in path "" relative to "" #6473

@pksjce

Description

@pksjce

🐛 bug report

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project
    adheres to.
  • I have searched the issue tracker for an issue that matches the one I want
    to file, without success.

Description of the problem

Seeing an 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

I reported the same bug under #6172.

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

We are unable to use @primer/react library in any codesandbox.

To Reproduce

  1. Create a react codesandbox
  2. Import components from @primer/react.
  3. Use in the codesandbox to see the error pop up.

Link to sandbox: link (optional)

Your Environment

Software Name/Version
Сodesandbox
Browser
Operating System

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions