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.
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)
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.
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)
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"
}
}
Can you run react-native info and edit your issue to include these results under the React Native version: section?
[skip envinfo] alongside an explanation in your Environment: section.
I wasn't able to reproduce this issue on MacOS. Additionally package.json you attached seems incomplete. Mine looks like this:
{
"name": "AppName",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.8"
},
"devDependencies": {
"@babel/core": "^7.4.5",
"@babel/runtime": "^7.4.5",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"metro-react-native-babel-preset": "^0.54.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
Are you sure initialisation process completed successfully?
What operating systems are you using?
There was a bad release of v1.9.6, which was fixed in 1.9.7, closing.
Got the exact same issue when running npx react-native init AppName and cannot figure out why. It worked one week ago when playing around with react native for the first time.
The error pops up when pod install is running.
My package.json:
{
"name": "BarcodeReader",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.9.0",
"react-native": "0.61.5"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/runtime": "^7.6.2",
"@react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.5.1",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
If you need more info, i will deliver.
Same error
For some weird reason it worked with yarn install and then doing the pod install
Yup, got it to work like that too, had to install yarn, since i never needed it before. But this seems like an disruptive issue - especially for a react newbie like me.
@diggamies i got same error. I didn't figure out why this is happening because yesterday i created a project without any errors.
Running into the same issue. I followed the steps in the osx / android setup guide and when trying to run npx react-native init myapp i run into this issue.
When i try to go myapp/ios and run pod install there i get:
[!] Invalid `Podfile` file: [!] /Users/user/.nvm/versions/node/v12.13.1/bin/node -e console.log(require('@react-native-community/cli').bin);
internal/modules/cjs/loader.js:800
throw err;
^
Error: Cannot find module '@react-native-community/cli'
Require stack:
- /Users/user/dev/myapp/ios/[eval]
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852: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:959:30)
at evalScript (internal/process/execution.js:80:25) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/user/dev/myapp/ios/[eval]' ]
}
.
# from /Users/user/dev/myapp/ios/Podfile:42
# -------------------------------------------
#
> use_native_modules!
# end
# -------------------------------------------
@joakimgrr I solved the issue. Check this out https://github.com/react-native-community/cli/issues/406#issuecomment-585961947
installing this solve the issue. npm i @react-native-community/cli
Also facing the same, is the fix published on npm?
What is the new resolved version of @react-native-community/cli which is fixed?
Starting with a fresh project (npx react-native init MyTestApp), when I run npm list @react-native-community/cli I get:
[email protected] /Users/user/Desktop/Projects/MyTestApp
└── (empty)
The bigger issue is that I can't run pod install, I get:
``` module.js:491
throw err;
^
Error: Cannot find module '/MyTestApp/node_modules/@react-native-community/cli/build/bin.js
```
However, I see @react-native-community/cli/build/bin.js in node_modules
@davidsalib that sounds like faulty installation, since yarn normally detects the CLI. Please try initializing again. Or npx react-native uses global version. Use npx --ignore-existing react-native to avoid using global (and please uninstall any global react-native/react-native-cli packages)
Thanks @thymikee! Turns out the issue was my node version.
incase it helps anybody in the future, this was the issue:
error @typescript-eslint/[email protected]: The engine "node" is incompatible with this module. Expected version "^6.14.0 || ^8.10.0 || >=9.10.0". Got "8.3.0"
Deleting the node modules folders and doing npm install worked for me
Most helpful comment
For some weird reason it worked with
yarn installand then doing thepod install