12

I'm using React-Native on my android program, after open my porject with react-native run-android ,the error occurred.The same error message occurred twice.

Unexpected identifier '_classCallCheck'.import call expects exactly one argument

Unexpected identifier '_classCallCheck'.import call expects exactly one argument

no stack

no stack

I googled this and try some solutions, but still can't resolve. Here is a similar problem that I have found: https://github.com/facebook/react-native/issues/23669

What I have been tried for this error:

  1. cd to /andorid, use gradlew clean
  2. use react-native start --reset-cache
  3. use npm install -g react-native-cli

Here is my develop environment:

Android: 
AVD version: Android 7.0 with Play Store    
System:
OS: Windows 10 10.0.19043
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 2.11 GB / 15.71 GB
Binaries:
Node: 10.16.0 - D:\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.9.0 - D:\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
  API Levels: 28, 32
  Build Tools: 28.0.3, 32.0.0
  System Images: android-24 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
  Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: Version     2020.3.0.0 AI-203.7717.56.2031.7935034
Visual Studio: Not Found
Languages:
Java: 1.8.0_232
npmPackages:
@react-native-community/cli: Not Found
react: 16.9.0 => 16.9.0
react-native: ^0.64.0 => 0.64.3
react-native-windows: Not Found
npmGlobalPackages:
*react-native*: Not Found

Guys,I just solved this problem.Here's the link. https://github.com/babel/babel/issues/14139

from:

module.exports = {
   presets: ['module:metro-react-native-babel-preset'],
};

to:

module.exports = {
   presets: [['module:metro-react-native-babel-preset', {
        unstable_disableES6Transforms: true
    }]],
};
DoubleXXXX
  • 121
  • 1
  • 1
  • 5
  • i have same issue here after upgrading to react native 0.65, still havent found the solution – d1mitar Jan 18 '22 at 08:55
  • 1
    i have similar issue on react 0.57.x, and even after upgrading to the latest version(0.67.1), the problem is still occurred. I use babel-preset-expo on my babel.config.js. is it possible that it was the one who cause the error? – Potamir Jan 27 '22 at 06:55
  • try first: `npx react-native start --reset-cache` – Ahmad hassan May 01 '23 at 11:08

6 Answers6

6

I had the same problem and the steps above didn't work, so i update metro-react-native-babel-preset from 0.56.0 to 0.59.0 and it worked.

3
"@babel/core": "7.12.0", // was "7.9.6"
"metro-react-native-babel-preset": "0.59.0", // was "0.58.0"

This helped me (RN 0.62.2)

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 22 '22 at 13:56
  • For me changing to "@babel/core": "7.20.5" worked RN 0.64.4 – Asaf Shveki Dec 21 '22 at 09:46
2

Thank God after days of work this silly issue resolved on my side

In my case it was babel, actually i removed the yarn.lock file and after a fresh yarn the babel version was updated so its creating this issue, so what i did i just revert the yarn.lock file and remove ( ^ ) from "@babel/core" version and did a yarn and then it works....

my current babel/core version is "@babel/core": "7.12.9",

i changed this

"@babel/core": "^7.12.9",

to this

"@babel/core": "7.12.9",

this issue also listed here

Dharman
  • 30,962
  • 25
  • 85
  • 135
Arslan Bajwa
  • 548
  • 4
  • 9
0

1.in your terminal enter:

npm ls metro-config

you will see your version of react-native need the version of metro-config

  1. change the version of these dependencies:
    "metro": "^0.59.0",
    "metro-core": "^0.59.0",
    "metro-react-native-babel-preset": "^0.59.0",
  1. Clear watchman watches: watchman watch-del-all
  2. Delete node_modules and run yarn install
  3. Reset Metro's cache by passing the --reset-cache flag, or adding
  4. resetCache: true to your metro configuration file.
  5. Remove the cache: rm -rf ${TMPDIR:-/tmp}/metro-*
  6. if necessary add
      resetCache: true,

in your metro.config.js

leooooooo
  • 400
  • 2
  • 12
0

I think you will need to upgrade the gradle version

Sami Ullah
  • 717
  • 8
  • 14
0

I solved this problem by installing the node version to 12.13.0.

When I encountered this problem, my node version was 16.x.0.

Install node 12.13.0:

sudo npm cache clean -f
sudo npm install -g n
sudo n 12.13.0

Some version infos in my package.json:

//...
  "dependencies": {
    "react": "16.9.0",
    "react-native": "0.61.5",
    //...
  },
  "devDependencies": {
    "@babel/core": "^7.6.2",
    "metro-react-native-babel-preset": "^0.56.0",
    //...
  },
//...

Reference:

tomfriwel
  • 2,575
  • 3
  • 20
  • 47