cli: Error: Cannot find module 'react-native/cli'
Environment
System: OS: macOS 12.3.1 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Memory: 809.65 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.15.0 - /usr/local/bin/node Yarn: 1.22.18 - /usr/local/bin/yarn npm: 6.13.4 - /usr/local/bin/npm Watchman: 2022.03.21.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8309675 Xcode: 13.2/13C90 - /usr/bin/xcodebuild Languages: Java: 12.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: Not Found react-native: 0.66.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Description
I am trying to upgrade the react-native version from 0.63 to 0.66 but I am getting this below error, already tried deleting node_modules, adding cli as dependency in package.json, tried with different gradle version, different npm and node versions.
` Starting a Gradle Daemon (subsequent builds will be faster) :ReactNative:Unexpected empty result of running ‘[node, -e, console.log(require(‘react-native/cli’).bin);]’ command. :ReactNative:Running ‘[node, -e, console.log(require(‘react-native/cli’).bin);]’ command failed.
FAILURE: Build failed with an exception.
-
Where: Script ‘node_modules/@react-native-community/cli-platform-android/native_modules.gradle’ line: 213
-
What went wrong: A problem occurred evaluating script.
internal/modules/cjs/loader.js:796 throw err; ^Error: Cannot find module 'react-native/cli’Require stack:- app/android-app/[eval] at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17) at Function.Module._load (internal/modules/cjs/loader.js:686:27) at Module.require (internal/modules/cjs/loader.js:848:19) at require (internal/modules/cjs/helpers.js:74:18) at [eval]:1:13 at Script.runInThisContext (vm.js:116:20) at Object.runInThisContext (vm.js:306:38) at Object.<anonymous> ([eval]-wrapper:9:26) at Module._compile (internal/modules/cjs/loader.js:955:30) at evalScript (internal/process/execution.js:80:25) { code: ‘MODULE_NOT_FOUND’, requireStack: [ ‘app/android-app/[eval]’ ]} `
but when running the command im my terminal, getting this file `
node -e “console.log(require(‘react-native/cli’).bin);” /Users/Desktop/app/android-app/node_modules/react-native/node_modules/@react-native-community/cli/build/bin.js `
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 16
- Comments: 19
Did you resolve this problem at last? I caught the same.
Hello Could you please check which version of node you’re using? Also, maybe
node_modules
are corrupted? Could you please try to remove them (and alsoyarn.lock
/package-lock.json
) and reinstall dependencies?I found the key in native_modules.gradle
same project with different dir got different output
this will force people use parent dir node_modules, can’t custom clipath now. integrate rn to exsting app, we really need a different js dir, not must be a parent dir. thanks. can some way resolve this? now I can only with patch-package
After I have reformed this way, I have encountered such mistakes:
Is this problem solved, brother? I also had this problem integrating 0.72.3
Hello,
Any fix about this issue. I can reproduce with react-native": “0.68.2” 😢