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

react-native init fails in Windows 10 #21029

Closed
3 tasks done
ancodeUDW opened this issue Sep 9, 2018 · 19 comments
Closed
3 tasks done

react-native init fails in Windows 10 #21029

ancodeUDW opened this issue Sep 9, 2018 · 19 comments
Labels
Bug Platform: Windows Building on Windows. Resolution: Locked This issue was locked by the bot.

Comments

@ancodeUDW
Copy link

ancodeUDW commented Sep 9, 2018

Environment

React Native Environment Info:
System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) 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/[email protected]".
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 [email protected] --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. (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 [email protected]

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

@react-native-bot
Copy link
Collaborator

It looks like you are using an older version of React Native. Please update to the latest release, v0.56 and verify if the issue still exists.

The ":rewind:Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

@ancodeUDW
Copy link
Author

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:

warning Unmet peer dependency "@babel/[email protected]".
error An unexpected error occured, please open a bug report with the information provided in "C:\\proyectos\\react-native\\cheerio2\\AwesomeProject\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
child_process.js:645
    throw err;
    ^

Error: Command failed: yarn add jest babel-jest babel-preset-react-native@^5 [email protected] --dev --exact
    at checkExecSyncError (child_process.js:602:13)
    at execSync (child_process.js:642:13)

after doing react-native info inside the created AwesomeProject it gives me the following info:

  React Native Environment Info:
    System:
      OS: Windows 10
      CPU: x64 Intel(R) Core(TM) 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

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:

{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"react": "16.4.1",
"react-native": "0.56.1"
}
}

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

@hramos
Copy link
Contributor

hramos commented Sep 11, 2018

This should be fixed in 0.57. Stable is right around the corner if you're willing to wait, otherwise you can use react-native init --version [email protected]

@ancodeUDW
Copy link
Author

ancodeUDW commented Sep 11, 2018

This should be fixed in 0.57. Stable is right around the corner if you're willing to wait, otherwise you can use react-native init --version [email protected]

Thank you for your reply.

I tried to run react-native init --version [email protected] test, and it still gave me the same "throw err" message.

this time in the last line of the yarn-error.log says:

Trace: 
  Error: ENOENT: no such file or directory, open 'C:\projects\react-native\test\node_modules\@babel\template\node_modules\to-fast-properties\index.js'

@hramos hramos added Platform: Windows Building on Windows. and removed ⏪Old Version labels Sep 11, 2018
@FibreFoX
Copy link

FibreFoX commented Oct 10, 2018

I'm currently re-checking stable versions that are working on Windows, so I might have found some things:

For me working versions are 0.55.4 and 0.57.1 that are being able to create and to compile (and running on my virtual android device). But I have found that latest/0.57.2 does not work (which is default when not having that version-flag specified), so you might want to create a new project using 0.57.1?

react-native init newproject0571 --version [email protected] 

@hramos for information, when using latest 0.57.2 on Windows I'm hitting issue #21617 ... EDIT: but was able to get it running via react-native start --reset-cache

@stale

This comment has been minimized.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 16, 2019
@ancodeUDW
Copy link
Author

Actually no, the problem has not been solved yet. I am using expo because it does work. I tried to install last react-native version again last December from scratch, and the same problems arise.

Expo is ok for my current project, but it might become a bit short for some projects I plan to start in the near future, so I would be interested to be able to develop properly with react-native.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 16, 2019
@hramos
Copy link
Contributor

hramos commented Jan 16, 2019

What about React Native 0.57.8 or 0.58.0-rc.2?

@shaktals
Copy link

I just experienced the same issue, but running on linux mint.
After 'react-native init newProject' I get:

error An unexpected error occurred: "/home/talles/.cache/yarn/v4/npm-jest-cli-24.1.0-f7cc98995f36e7210cce3cbb12974cbf60940843/node_modules/jest-cli/.yarn-metadata.json: Unexpected end of JSON input".

info If you think this is a bug, please open a bug report with the information provided in "/home/tallles/Projects/tests/compara/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
child_process.js:661
throw err;
^

Error: Command failed: yarn add jest babel-core@^7.0.0-bridge.0 babel-jest metro-react-native-babel-preset [email protected] --dev --exact
at checkExecSyncError (child_process.js:621:11)
at execSync (child_process.js:658:13)
at generateProject (/home/talles/Projects/tests/compara/node_modules/react-native/local-cli/init/init.js:96:7)
at Object.init (/home/talles/Projects/tests/compara/node_modules/react-native/local-cli/init/init.js:45:3)
at run (/home/talles/.nvm/versions/node/v11.4.0/lib/node_modules/react-native-cli/index.js:302:7)
at createProject (/home/talles/.nvm/versions/node/v11.4.0/lib/node_modules/react-native-cli/index.js:249:3)
at init (/home/talles/.nvm/versions/node/v11.4.0/lib/node_modules/react-native-cli/index.js:200:5)
at Object. (/home/talles/.nvm/versions/node/v11.4.0/lib/node_modules/react-native-cli/index.js:153:7)
at Module._compile (internal/modules/cjs/loader.js:723:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)

----x----

Here is the yarn error log:

yarn-error.log

@shaktals
Copy link

shaktals commented Feb 15, 2019

Using RN 0.57.8 or 0.58.0-rc.2 I get:

error An unexpected error occurred: "/home/talles/.cache/yarn/v4/npm-p-locate-3.0.0-322d69a05c0264b25997d9f40cd8a891ab0064a4/node_modules/p-locate/.yarn-metadata.json: Unexpected end of JSON input".
info If you think this is a bug, please open a bug report with the information provided in "/home/talles/Projects/tests/compara/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
child_process.js:661
throw err;
^

Error: Command failed: yarn add jest babel-jest metro-react-native-babel-preset [email protected] --dev --exact

@luziferAzazel
Copy link

luziferAzazel commented Feb 22, 2019

What about React Native 0.57.8 or 0.58.0-rc.2?

I use version 0.58.5 and I also have this issue, expo is working but it's not optimal.

P.S.
I know for some people this may not be a proper solution, and it's not. But what fixed it for me was to actually restart android studio.

@shaktals
Copy link

Running 'yarn cache clean' solved for me.

@thymikee
Copy link
Contributor

This seems like an environment issue (with Yarn or Android Studio or Node), there's likely nothing we can do more about it. I'm gonna close it, because it seems like there's not many users encountering this.

@FibreFoX
Copy link

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" ;)

@thymikee
Copy link
Contributor

Does it still happen for you? We usually get quite a lot of upvotes for the issues that happen for more users, so I assume this is just environmental issue, as solutions vary per user

@ancodeUDW
Copy link
Author

It always happened to me when working with react-native init. I tried everything. But as the system did work with expo I ended moving to it and to forget to use pure react-native.

over this last months I have been doing a lot of changes and updates in node, npm, react-native, expo and android studio. In order to test it for this comment I tried to do run

react-native init test

It also failed to finish the init.

error message:

child_process.js:645
throw err;
^

Error: Command failed: yarn add -D @babel/core @babel/runtime jest babel-jest metro-react-native-babel-preset [email protected]
at checkExecSyncError (child_process.js:602:13)
at execSync (child_process.js:642:13)
at executeCommand (C:\proyectos\react-native\test\test\node_modules@react-native-community\cli\build\tools\PackageManager.js:26:40)
at Object.installDev (C:\proyectos\react-native\test\test\node_modules@react-native-community\cli\build\tools\PackageManager.js:48:35)
at generateProject (C:\proyectos\react-native\test\test\node_modules@react-native-community\cli\build\commands\init\init.js:116:18)
at Object.init (C:\proyectos\react-native\test\test\node_modules@react-native-community\cli\build\commands\init\init.js:94:3)
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. (C:\Users\ancode\AppData\Roaming\npm\node_modules\react-native-cli\index.js:153:7)

I might do more tests with it today if I have a bit of time.

@thymikee
Copy link
Contributor

We're working on a new init command for 0.60, feel free to try it: https://github.com/react-native-community/cli/blob/master/docs/init.md

Here's sample template: https://github.com/Esemesek/react-native-new-template so you can use it like this for now:

npx @react-native-community/cli init ProjectName --template react-native-new-template

@Michel-Lobo
Copy link

This error happens because of some conflict between yarn and npm. I took off yarn and everything worked

@overbound
Copy link

overbound commented Aug 21, 2019

Why is this closed? There is no definitive answer and it is happening to me in Windows 10 too.

@facebook facebook locked as resolved and limited conversation to collaborators Apr 25, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Windows Building on Windows. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants