Error: Cannot find module 'react-native/cli'

See original GitHub issue

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 `

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:11
  • Comments:7

github_iconTop GitHub Comments

5reactions
CPPAliencommented, Aug 8, 2022

Did you resolve this problem at last? I caught the same.

1reaction
sanders9commented, Oct 31, 2022

Hello,

Any fix about this issue. I can reproduce with react-native": “0.68.2” 😢

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module 'react-native/cli' · Issue #995 - GitHub
I have the same issue. It happens in monorepos that have RN projects inside /mobile , /app or something like that. App Center...
Read more >
Module not found @react-native-community-cli - Stack Overflow
If you got error Error: Cannot find module '/node_modules/react-native/local-cli/cli.js' in App Center build, then you need to:.
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
To fix the error, you need to install the package that is absent in your project directory – npm install package-name or yarn...
Read more >
@react-native-community/cli-tools - npm
Start using @react-native-community/cli-tools in your project by running `npm i ... This package does not have a README.
Read more >
react-native integration with existing native project getting ...
Coding example for the question react-native integration with existing native project getting error Cannot find module 'react-native/cli'
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found