Make sure that you have followed the environment setup instructions properly from the official React Native docs.
The installation command will fail if you have the global legacy
react-native-cliinstalled in your machine. Make sure you uninstall it first:
yarn global remove react-native-cli
or if using
npm uninstall -g react-native-cli
Generate a new React Native(v0.69.4) app using the @ajaysidhu/react-native-template:
npx react-native init MyApp --template @ajaysidhu/react-native-template --skip-install
You might also be prompted to confirm the installation for the packages
husky. Simply hit
enter to proceed.
The template will automatically install the
npm dependencies and the
pods (if you are on the MacOS).
If you want to use the template directly from the
GitHub or try out the latest features which are not release to the
npm yet, then you can run:
npx react-native init MyApp --template https://github.com/ajaykumar97/react-native-template.git --skip-install
If you want to use an older version of the template, then you can run(replace
version with your desired version):
npx react-native init MyApp --template @ajaysidhu/react-native-template@version --skip-install
You can look at all versions, that I have published here.
If you want to extend the setup further to configure different bundle ids, App Names and Google Service files for Staging and Production environments, you can follow my this Medium post.
Enjoying this awesome template feature of
react-native-cli and want to build your own react-native-template? No worries! I have written a dedicated post to create your own
react-native-template based your own project needs. You can give it a read here.