React-native: Error: UNKNOWN: unknown error, open 'C:\Users\me\.babel.json'

Created on 10 Jan 2017  路  12Comments  路  Source: facebook/react-native

This warning is produced when I initialize a new ReactNative project: react-native init Test

npm WARN [email protected] requires a peer of react@~15.4.0-rc.4 but none was
installed.

npm WARN prefer global [email protected] should be installed with -g

and when I run react-native start from inside the project folder I get this error:

Error: UNKNOWN: unknown error, open 'C:UsersMe\.babel.json'
at Object.fs.openSync
at Object.fs.writeFileSync
at save

and when the app launches on my device it shows:

Could not get BatchedBridge, make sure your bundle is packaged correctly

  • React Native version: react-native-cli: 2.0.1
  • Platform: Android
  • Operating System: Windows 7
Locked

Most helpful comment

Hey there,
I have run into this as well and debugged it as far as I could right now. The error arises from some race condition:

  • during the build, babel-register writes a cache to ~/.babel.json, on every tick
  • since the write is synchronous, the race condition cannot arise within a single node thread
  • since node is single-threaded by design, this must be on account of some parallel execution in Java, triggering several parallel node threads

I have no idea why this doesn't happen to everybody or why this only happens after having used react native for some time...

This will need to be fixed in React Native, probably in coordination with babel-register...

I have posted this into the related StackOverflow question as well.

All 12 comments

To fix the react warning ensure React at version 15.4.0-rc.4 is also installed to your project. I thought it got installed with init but it seems that may not be the case here.

Not sure what is going on with the marked dependency. I am not sure that it is a React Native dependency at all.

You have a babel.json file at C:UsersMe that is invalid. Fix that or remove that. This was not created by React Native and is not needed unless you want to set some global babel settings for every project on your machine.

You are seeing that error because the packager failed to start because of the babel issue.

@rmevans9 how do I check if that version is installed to my project? The only variable I know how to get hold of is "react-native-cli: 2.0.1" . I managed to fix the babel.json issue by reinstalling everything a third time for some reason.

All installed packages are listed in the package.json file in your project folder. You can also run npm list --depth=0 in your project folder to see the version of all installed packages.

@rmevans9 Well it seems I have 2 versions above?
"dependencies": { "react": "15.4.2", "react-native": "0.40.0" },

so do I need to downgrade or something?

Not really - you can likely just let React stay the way it is as React Native will eventually catch up and use that version of React.

Hey there,
I have run into this as well and debugged it as far as I could right now. The error arises from some race condition:

  • during the build, babel-register writes a cache to ~/.babel.json, on every tick
  • since the write is synchronous, the race condition cannot arise within a single node thread
  • since node is single-threaded by design, this must be on account of some parallel execution in Java, triggering several parallel node threads

I have no idea why this doesn't happen to everybody or why this only happens after having used react native for some time...

This will need to be fixed in React Native, probably in coordination with babel-register...

I have posted this into the related StackOverflow question as well.

Why was this issue closed? I'm still running into this issue

I was having this same issue, and for me deleting node_modules and reinstalling everything worked. I'm not sure if it was a permissions issue or I just needed to get the latest packages, but either way that got my build working again. (Windows 10).

I had the same issue (Windows 10) and disabling Babel's cache solved it. https://babeljs.io/docs/usage/babel-register/#environment-variables-babel-disable-cache

I am facing this issue too. Using almost the same environment. Why was this issue closed? I follow the get-start tutorian and came out this issue. I think this should be an issue not a question.

Re-opening the issue since no solution was found and lots of other people seem to have the same problem.

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DreySkee picture DreySkee  路  3Comments

WG-Com picture WG-Com  路  3Comments

anchetaWern picture anchetaWern  路  3Comments

oney picture oney  路  3Comments

jlongster picture jlongster  路  3Comments