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

Unable to resolve module @swc/helpers/cjs/_class_private_field_init.cjs from /Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/@react-aria/interactions/dist/main.js #4894

Closed
michaelroevievictoria opened this issue Aug 10, 2023 · 25 comments

Comments

@michaelroevievictoria
Copy link

Provide a general summary of the issue here

I have an error

Error: Unable to resolve module @swc/helpers/cjs/_class_private_field_init.cjs from /Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/@react-aria/interactions/dist/main.js: @swc/helpers/cjs/_class_private_field_init.cjs could not be found within the project or in these directories:
  node_modules
  ../node_modules
  ../../../node_modules
  2 | var $goTMa$react = require("react");
  3 | var $goTMa$swchelperscjs_class_private_field_getcjs = require("@swc/helpers/cjs/_class_private_field_get.cjs");
> 4 | var $goTMa$swchelperscjs_class_private_field_initcjs = require("@swc/helpers/cjs/_class_private_field_init.cjs");
    |                                                                 ^
  5 | var $goTMa$swchelperscjs_class_private_field_setcjs = require("@swc/helpers/cjs/_class_private_field_set.cjs");
  6 | var $goTMa$reactariassr = require("@react-aria/ssr");
  7 |
    at ModuleResolver.resolveDependency (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:158:15)
    at DependencyGraph.resolveDependency (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
    at Object.resolve (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/lib/transformHelpers.js:129:24)
    at resolve (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
    at /Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
    at processModule (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
    at async addDependency (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18)
    at async Promise.all (index 2)
   

Not sure if some libraries connected to another libraries

but im using native-base

Im not using @swc/helpers

🤔 Expected Behavior?

it should be work and not having an error I also try to path but it show well in vscode.

😯 Current Behavior

Error: Unable to resolve module @swc/helpers/cjs/_class_private_field_init.cjs from /Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/@react-aria/interactions/dist/main.js: @swc/helpers/cjs/_class_private_field_init.cjs could not be found within the project or in these directories:
  node_modules
  ../node_modules
  ../../../node_modules
  2 | var $goTMa$react = require("react");
  3 | var $goTMa$swchelperscjs_class_private_field_getcjs = require("@swc/helpers/cjs/_class_private_field_get.cjs");
> 4 | var $goTMa$swchelperscjs_class_private_field_initcjs = require("@swc/helpers/cjs/_class_private_field_init.cjs");
    |                                                                 ^
  5 | var $goTMa$swchelperscjs_class_private_field_setcjs = require("@swc/helpers/cjs/_class_private_field_set.cjs");
  6 | var $goTMa$reactariassr = require("@react-aria/ssr");
  7 |
    at ModuleResolver.resolveDependency (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:158:15)
    at DependencyGraph.resolveDependency (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
    at Object.resolve (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/lib/transformHelpers.js:129:24)
    at resolve (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:396:33)
    at /Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:412:26
    at Array.reduce (<anonymous>)
    at resolveDependencies (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:411:33)
    at processModule (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:140:31)
    at async addDependency (/Users/mrv/Desktop/Projects/art-hearts-mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:230:18)
    at async Promise.all (index 2)
   

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

hmmmm I just run the app it tells me the error its your library ???

Version

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

mbp m2

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@reidbarber
Copy link
Member

reidbarber commented Aug 10, 2023

Can you specify which version of React Aria you're using, and which build tool you're using for your app?

@jakecrump
Copy link

jakecrump commented Aug 10, 2023

Having the same issue. Unsure if it impacts other packages but specifically for me, @react-aria/button version 3.8.1 is causing the above error. I added an override to an earlier version (3.8.0) and the error goes away.

edit: upon further investigating, seems outside of the button component. Apologies.

@michaelroevievictoria
Copy link
Author

@reidbarber Im using react-native, actually im not sure why the error comes on this library I have already suspected that this issue is within the native-base but I try to bump up the library but the error goes still the same .

image

Can you specify which version of React Aria you're using, and which build tool you're using for your app?

@michaelroevievictoria
Copy link
Author

michaelroevievictoria commented Aug 10, 2023

Added info

image

image

@reidbarber
Copy link
Member

@jakecrump which build tool and version are you using for your app? Does this happen to be an older version of Next.js?

@reidbarber
Copy link
Member

@michaelroevievictoria is this using Expo? If so, which version?

@michaelroevievictoria
Copy link
Author

@reidbarber im using react native cli

"react-native": "0.69.3",
"native-base": "3.2.2-rc.3",

@jakecrump
Copy link

@jakecrump which build tool and version are you using for your app? Does this happen to be an older version of Next.js?

Yeah, it's Next 12.3.2 (updating to 13 is not possible at this time)

@LFDanLu
Copy link
Member

LFDanLu commented Aug 10, 2023

I believe this issue is the same as this one, see this comment for more details.

@jakecrump
Copy link

Since it's a third-party module for my case, I'm unable to manually downgrade (for now). Fortunately, adding this override to the package.json seems to work until a more permanent solution can be explored.

  "overrides": {
    "@react-aria/interactions": "3.16.0"
  }

@devongovett
Copy link
Member

Seems like two different issues? One is for Next.js, which we know about already, and the other is for React Native? For the React Native folks, could you verify what version of @swc/helpers is installed? Maybe try clearing it from your lockfile and reinstalling?

@jakecrump
Copy link

For what its worth (On the Next js side of this issue), we're generating, cloning, and installing Next 12.3.2 apps on a daily basis, and I can confirm this was not an issue yesterday (I did several installs yesterday with fresh package-locks, the whole works). So if the issue thread from last month that @LFDanLu shared earlier is in fact what's happening, I'm guessing this latest release is just a continuation of losing Next 12 support and we were just lucky until now?

@dcisneros2
Copy link

The issue is happening on react-native, started last night since builds were working before, looks like it lines up with react-aria/interactions update. Not using dependency directly but react-native-base uses it.

@swc/helpers version referenced is 0.51.0, but this we are also not using directly.

@devongovett
Copy link
Member

devongovett commented Aug 10, 2023

Looking inside @swc/helpers, it looks like the requested file does exist: https://unpkg.com/browse/@swc/helpers@0.5.1/cjs/_class_private_field_init.cjs

Can you verify what version of Metro bundler you are using? Looks like .cjs file support was added around a year ago in 0.72.0. facebook/metro#535

@devongovett
Copy link
Member

devongovett commented Aug 10, 2023

Oh, looks like at least one of you is using react-native 0.69.3 according to the above comment. That version is over a year old and marked as deprecated on npm: https://www.npmjs.com/package/react-native/v/0.69.3. Looks like it is also using an old version of metro from before .cjs support was added. Any chance you can upgrade your version?

@dcisneros2
Copy link

Using ^0.71.1 of metro. React native 0.66.

Upgrading will be pretty difficult to do. Dependencies in current project are not compatible with later node.

@devongovett
Copy link
Member

Hmm. I'm not really sure what we can do here. We don't control the @swc/helpers project, it's just used as part of our build.

Maybe you can try to configure your version metro so it accepts .cjs files? This comment might provide a clue about how to do it. facebook/metro#535 (comment) I haven't personally used React Native or Metro so I'm not sure how much more I can help.

@michaelroevievictoria
Copy link
Author

michaelroevievictoria commented Aug 10, 2023

I solve mine , my issue now is within "react-native": "0.69.3"

  1. Create metro.config.js:

Create a metro.config.js file in the root directory of your React Native CLI project if it doesn't already exist.

  1. Adjust Configuration:
    Open the metro.config.js file and configure Metro's resolver to include the .cjs extension:

  2. Adjust Module Imports:
    Open the metro.config.js file and configure Metro's resolver to include the .cjs extension:

module.exports = {
  resolver: {
    sourceExts: ['js', 'json', 'ts', 'tsx', 'cjs'], // Add 'cjs' as a source extension
  },
};

@VAIMORSS
Copy link

@michaelroevievictoria it worked for me :)

@mengpangyu
Copy link

@michaelroevievictoria

RN version is "react-native": "0.63.3", it worked for me, thanks

@karthikeyancontus
Copy link

module.exports = {
resolver: {
sourceExts: ['js', 'json', 'ts', 'tsx', 'cjs'], // Add 'cjs' as a source extension
},
};
RN version is "react-native" : "0.69.12", it worked for me

@devongovett
Copy link
Member

For those of you using Next.js on this thread, I reached out to the Vercel folks and they were nice enough to backport a fix to @swc/helpers that you can use with Next v12! See vercel/next.js#48593 (comment) for how to override the version with your package manager.

@sidalikharef
Copy link

I solve mine , my issue now is within "react-native": "0.69.3"

  1. Create metro.config.js:

Create a metro.config.js file in the root directory of your React Native CLI project if it doesn't already exist.

  1. Adjust Configuration:
    Open the metro.config.js file and configure Metro's resolver to include the .cjs extension:
  2. Adjust Module Imports:
    Open the metro.config.js file and configure Metro's resolver to include the .cjs extension:
module.exports = {
  resolver: {
    sourceExts: ['js', 'json', 'ts', 'tsx', 'cjs'], // Add 'cjs' as a source extension
  },
};

it worked for me Thanks 🌹

@MarcosJBM
Copy link

I solve mine , my issue now is within "react-native": "0.69.3"

  1. Create metro.config.js:

Create a metro.config.js file in the root directory of your React Native CLI project if it doesn't already exist.

  1. Adjust Configuration:
    Open the metro.config.js file and configure Metro's resolver to include the .cjs extension:
  2. Adjust Module Imports:
    Open the metro.config.js file and configure Metro's resolver to include the .cjs extension:
module.exports = {
  resolver: {
    sourceExts: ['js', 'json', 'ts', 'tsx', 'cjs'], // Add 'cjs' as a source extension
  },
};

This solved my problem, thanks

The version of React Native i'm using is 0.66.4, if anyone wants to know.

julien040 added a commit to julien040/pacifiscan that referenced this issue Sep 30, 2023
Thanks to this issue: adobe/react-spectrum#4894,
I have discovered that react-aria is faulty.

Pinning the version with the overrides field in npm allows building
julien040 added a commit to julien040/pacifiscan that referenced this issue Sep 30, 2023
Summary:
To ensure ongoing development and address security issues, Expo has been updated to version 49.
In order to fix an issue (missing function in @swc/helpers) in react-aria (a dependency of native-base), the version of this dependency had to be pinned.

* 📌 Pin @react-aria/interactions to 3.16.0

Thanks to this issue: adobe/react-spectrum#4894,
I have discovered that react-aria is faulty.

Pinning the version with the overrides field in npm allows building

* 📌 Expo SDK set to 47

* 📌 Pin expo SDK to v49
@samuelprogramer
Copy link

Using "react-native": "0.72.5",

I solve mine , my issue now is within "react-native": "0.69.3"

  1. Create metro.config.js:

Create a metro.config.js file in the root directory of your React Native CLI project if it doesn't already exist.

  1. Adjust Configuration:
    Open the metro.config.js file and configure Metro's resolver to include the .cjs extension:
  2. Adjust Module Imports:
    Open the metro.config.js file and configure Metro's resolver to include the .cjs extension:
module.exports = {
  resolver: {
    sourceExts: ['js', 'json', 'ts', 'tsx', 'cjs'], // Add 'cjs' as a source extension
  },
};

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