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

Can't resolve 'React' Error #10

Open
bolander72 opened this issue Sep 22, 2024 · 1 comment
Open

Can't resolve 'React' Error #10

bolander72 opened this issue Sep 22, 2024 · 1 comment

Comments

@bolander72
Copy link

bolander72 commented Sep 22, 2024

Heads up that after npm installing in a Next.js app, I was confronted with this error when trying to run the dev server locally.

Below is Claude response generated about the problem.

The error "Can't resolve 'React'" typically occurs when the module is trying to import React but can't find it. In this case, the issue is likely due to how the UMD (Universal Module Definition) wrapper is set up. Let's modify the code to fix this issue.

Here's the updated version of the relevant part of the file:

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.TellerConnect=t(require("react")):e.TellerConnect=t(e.react)}(self,(e=>(()=>{"use strict";
// ... rest of the code remains unchanged

Changes made:
Changed ["React"] to ["react"] in the AMD define section.
Changed e.React to e.react in the last part of the UMD wrapper.

These changes ensure that the module looks for "react" (lowercase) instead of "React" (uppercase), which is the correct way to import React in most modern setups.

Explanation:
The UMD wrapper is designed to work in different environments (CommonJS, AMD, global variable). The error you're seeing suggests that it's failing to resolve "React" with a capital "R". By changing it to lowercase "react", we're aligning it with the standard Node.js and bundler import conventions.

If you're still encountering issues after this change, make sure that:

  1. React is properly installed in your project.
  2. Your bundler (e.g., webpack, rollup) is configured correctly to resolve React.
  3. You're using the correct import statement for React in your components (e.g., import React from 'react').
@maurot0p
Copy link

I opened a PR for this, this happened to me when building with this package in Linux. It was not problem with MacOS due to case sensitivity

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

2 participants