'React native: Error "Unexpected identifier '_classCallCheck'.import call expects exactly one argument"
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:
- cd to /andorid, use
gradlew clean - use
react-native start --reset-cache - 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
}]],
};
Solution 1:[1]
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.
Solution 2:[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
Solution 3:[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)
Solution 4:[4]
1.in your terminal enter:
npm ls metro-config
you will see your version of react-native need the version of metro-config
- change the version of these dependencies:
"metro": "^0.59.0",
"metro-core": "^0.59.0",
"metro-react-native-babel-preset": "^0.59.0",
- Clear watchman watches: watchman watch-del-all
- Delete node_modules and run yarn install
- Reset Metro's cache by passing the --reset-cache flag, or adding
- resetCache: true to your metro configuration file.
- Remove the cache: rm -rf ${TMPDIR:-/tmp}/metro-*
- if necessary add
resetCache: true,
in your metro.config.js
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Pietro Paolo |
| Solution 2 | Dharman |
| Solution 3 | ???? ?????? |
| Solution 4 |
