react-native: Cannot find module '@react-native-community/cli'
Environment
Running ‘react-native info’ throws that error as well.
internal/modules/cjs/loader.js:584 throw err; ^
Error: Cannot find module ‘@react-native-community/cli’ at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15) at Function.Module._load (internal/modules/cjs/loader.js:508:25) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at Object.<anonymous> (E:\Projects\Hady\ProcoorCommunication\node_modules\react-native\cli.js:12:11) at Module._compile (internal/modules/cjs/loader.js:701:30) at Object.Module._extensions…js (internal/modules/cjs/loader.js:712:10) at Module.load (internal/modules/cjs/loader.js:600:32) at tryModuleLoad (internal/modules/cjs/loader.js:539:12) at Function.Module._load (internal/modules/cjs/loader.js:531:3)
Description
Running ‘react-native init AppName’ results in this error (Cannot find module ‘@react-native-community/cli’)
internal/modules/cjs/loader.js:584 throw err; ^
Error: Cannot find module ‘@react-native-community/cli’ at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15) at Function.Module._load (internal/modules/cjs/loader.js:508:25) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at Object.<anonymous> (E:\Projects\Hady\ProcoorCommunication\node_modules\react-native\cli.js:12:11) at Module._compile (internal/modules/cjs/loader.js:701:30) at Object.Module._extensions…js (internal/modules/cjs/loader.js:712:10) at Module.load (internal/modules/cjs/loader.js:600:32) at tryModuleLoad (internal/modules/cjs/loader.js:539:12) at Function.Module._load (internal/modules/cjs/loader.js:531:3)
Reproducible Demo
Run ‘react-native init AppName’ after it finishes it will try to run cli.js at ‘node_modules\react-native\local-cli\cli.js’ but it fails and throws that error ‘Error: Cannot find module ‘@react-native-community/cli’’
package.json
{
"name": "ProcoorCommunication",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/cli.js start"
},
"dependencies": {
"react-native": "0.59.8"
}
}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (4 by maintainers)
For some weird reason it worked with
yarn install
and then doing thepod install
installing this solve the issue. npm i @react-native-community/cli
@davidsalib that sounds like faulty installation, since yarn normally detects the CLI. Please try initializing again. Or
npx react-native
uses global version. Usenpx --ignore-existing react-native
to avoid using global (and please uninstall any global react-native/react-native-cli packages)Starting with a fresh project (
npx react-native init MyTestApp
), when I runnpm list @react-native-community/cli
I get:The bigger issue is that I can’t run pod install, I get:
However, I see
@react-native-community/cli/build/bin.js
innode_modules
Thanks @thymikee! Turns out the issue was my node version.
incase it helps anybody in the future, this was the issue:
@joakimgrr I solved the issue. Check this out https://github.com/react-native-community/cli/issues/406#issuecomment-585961947