react-native: react-native init fails in Windows 10
- Review the documentation: https://facebook.github.io/react-native
- Search for existing issues: https://github.com/facebook/react-native/issues
- Use the latest React Native release: https://github.com/facebook/react-native/releases
Environment
React Native Environment Info: System: OS: Windows 10 CPU: x64 Intel® Core™ i7-7740X CPU @ 4.30GHz Memory: 8.38 GB / 15.93 GB Binaries: npm: 6.2.0 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 2.2.0.0 AI-145.3360264
[skip envinfo]
Description
I develop with Windows. I started a new react-native project after updating react-native, using react-native init myApp. However, it fails before ending the the initialization of the project. The message it leaves is:
warning Unmet peer dependency “@babel/core@7.0.0-beta.47”. error An unexpected error occured, please open a bug report with the information provided in “C:\proyects\myapp\yarn-error.log”. info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command. child_process.js:644 throw err; ^
Error: Command failed: yarn add jest babel-jest babel-preset-react-native@^5 react-test-renderer@16.4.1 --dev --exact at checkExecSyncError (child_process.js:601:13) at execSync (child_process.js:641:13) at generateProject (C:\proyectos\react-native\cheerio2\myapp3\node_modules\react-native\local-cli\init\init.js:105:7) at Object.init (C:\proyectos\react-native\cheerio2\myapp3\node_modules\react-native\local-cli\init\init.js:53:5) at run (C:\Users\ancode\AppData\Roaming\npm\node_modules\react-native-cli\index.js:302:7) at createProject (C:\Users\ancode\AppData\Roaming\npm\node_modules\react-native-cli\index.js:249:3) at init (C:\Users\ancode\AppData\Roaming\npm\node_modules\react-native-cli\index.js:200:5) at Object.<anonymous> (C:\Users\ancode\AppData\Roaming\npm\node_modules\react-native-cli\index.js:153:7) at Module._compile (module.js:652:30) at Object.Module._extensions…js (module.js:663:10)
when checking C:\proyects\myapp\yarn-error.log" its two last lines said:
Trace: Error: ENOENT: no such file or directory, open ‘C:\proyecto\myApp\node_modules@babel\highlight\node_modules\ansi-styles\index.js’
If I try to do a
npm install
inside of the project’s folder and when it is finished I execute
react-native run-android
it gives the following error (I assume that it is becuse it was not properly initialized):
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Before the update, I could use react-native init whitout any problem. I have been trying fixes and alternatives, like
react-native init {proj_name} --version react-native@0.55.4
but the same error arises. The only way I could create a react-native project by now is via “create-react-native-app”, but it limits me because I cannot install native modules.
Reproducible Demo
react-native init myApp
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 19 (5 by maintainers)
Why is this closed? There is no definitive answer and it is happening to me in Windows 10 too.
not many users encountering this
seems so Apple-like … please don’t advocate this form of “solution” by just turning against us “small number of users” 😉Running ‘yarn cache clean’ solved for me.
I have reinstalled node to the latest version, uninstall react-native-cli and installed it again with a global flag
npm install react-native-cli -g
After that, I tried to run
react-native init AwesomeProject
It throws an error and it still the same:
after doing
react-native info
inside the created AwesomeProject it gives me the following info:In this case no mention of the packages. I did an npm install inside the project, but the information running the same instruction is the same.
The AwesomeProject project’s package.js content is the following:
So I understand is the last react-native version. Checking the other projects I created before the reinstalation, I can see that their package.js was basically the same, only diference that the react-native installed was 0.56.0, I created several projects to test
react-native init
and only one had the react native version 0.55.4, so I presume I happened to enter to that precise project when I was creating this issue