After ejecting, none of the react-native tasks seem to work. I'm not sure if this problem is related to create-react-native-app (or at least could be solved here), but I would like to report it anyway.
I guess it should just work.
Got the folling message:
Looks like you installed react-native globally, maybe you meant react-native-cli?
To fix the issue, run:
npm uninstall -g react-native
npm install -g react-native-cli
error Command failed with exit code 1.
Even after running those commands, the problem is still here.
Please run these commands in the project folder and fill in their results:
npm ls react-native-scripts: (empty)npm ls react-native: 0.46.1 (tried 0.47.1 too)npm ls expo: node -v: 8.3.0npm -v: 5.3.0yarn --version: 0.27.5watchman version: 4.9.0Also specify:
create-react-native-appejectandroid or any other taskExactly the same environment and error here.
Same error but maybe, but I found the solution for me here
https://github.com/facebook/react-native/issues/4515#issuecomment-173302985
I can confirm the same. I followed all the create-react-native-app instructions on my mac, ejected. Build and ran fine on Mac using "start": "react-native start",. Then moved over to my PC and had the same issue described above. changed it to '"start": "node node_modules/react-native/local-cli/cli.js start"` and it now works as expected.
These could do with being updated:
https://github.com/react-community/create-react-native-app/blob/7203fc975b0cfeba38d136c4414a0ca26807162b/react-native-scripts/src/scripts/eject.js#L196
I confirm:
"android": "node node_modules/react-native/local-cli/cli.js run-android"
works fine
I can confirm the same. I followed all the create-react-native-app instructions on my mac, ejected. Build and ran fine on Mac using "start": "react-native start",. Then moved over to my PC and had the same issue described above. changed it to '"start": "node node_modules/react-native/local-cli/cli.js start"` and it now works as expected.
I don't understand where to perform this. Please, help.
@albian I think this is in the projects package.json in the scripts: {}
Thanks a lot, that's right, but I'm getting the same error...
What I've found is that instead of cli.js the command points to wrong-react-native.js. Where could be the instruction to get the CLI to point to cli.js ? I already modified the package.json as suggested with no result.
After forking the react-native repo, I ran into this issue as well.
@albian, for a quick workaround, I was able to comment out the offending code in my local copy of react-native.
wrong-react-native.js
if (installedGlobally) {
// const chalk = require('chalk');
// console.error([
// chalk.red('Looks like you installed react-native globally, maybe you meant react-native-cli?'),
// chalk.red('To fix the issue, run:'),
// 'npm uninstall -g react-native',
// 'npm install -g react-native-cli'
// ].join('\n'));
// process.exit(1);
// } else {
require('./cli').run();
}
I then created a symlink via npm link inside of the react-native root directory and linked that to my project via npm link react-native inside of my project's root directory. Another attempt at a react-native run-ios didn't show the error, and the build succeeded.
Since I was using the react-native cli, I can't guarantee that the solution will be as painless for expo, but I hope it works for you!
Most helpful comment
I confirm:
"android": "node node_modules/react-native/local-cli/cli.js run-android"works fine