Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect checking for "installed react-native globally" in Windows. #197

Closed
weifuchuan opened this issue Mar 3, 2019 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@weifuchuan
Copy link

weifuchuan commented Mar 3, 2019

Environment

λ react-native init xxx --version react-native@next
...
λ yarn react-native run-android
yarn run v1.13.0 
$ E:\code\rn-next\xxx\node_modules\.bin\react-native run-android
error 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.

Description

The problem is to checked path error in function isInstalledGlobally:

// packages/cli/src/util/isInstalledGlobally.js
export default function isInstalledGlobally() {
  if (isWindows) {
    // On Windows, assume we are installed globally if we can't find a
    // package.json above node_modules.
    return !fs.existsSync(path.join(__dirname, '../../../package.json'));
  }
  // On non-windows, assume we are installed globally if we are called from
  // outside of the node_mobules/.bin/react-native executable.
  const script = process.argv[1];
  return script.indexOf('node_modules/.bin/react-native') === -1;
}

RN0.59.0.rc project init will not exists '../../../package.json' that is 'node_modules/@react-native-community/package.json' . Now I must be create it voluntarily to ignore the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant