5

I have a RN developing environment on Windows 7. It works fine until yesterday it suddenly reports error after I run "react-native" start. The error Message:

[2016-12-26 09:58:17]         HMR Server listening on /hot

React packager ready.

fs.js:557
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: UNKNOWN: unknown error, open 'C:\Users\xitao\.babel.json'
    at Object.fs.openSync (fs.js:557:18)
    at Object.fs.writeFileSync (fs.js:1222:33)
    at save (C:\RN\LearnRN\node_modules\babel-register\lib\cache.js:45:16)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
fs.js:557
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: UNKNOWN: unknown error, open 'C:\Users\xitao\.babel.json'
    at Object.fs.openSync (fs.js:557:18)
    at Object.fs.writeFileSync (fs.js:1222:33)
    at save (C:\RN\LearnRN\node_modules\babel-register\lib\cache.js:45:16)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
fs.js:557
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: UNKNOWN: unknown error, open 'C:\Users\xitao\.babel.json'
    at Object.fs.openSync (fs.js:557:18)
    at Object.fs.writeFileSync (fs.js:1222:33)
    at save (C:\RN\LearnRN\node_modules\babel-register\lib\cache.js:45:16)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I google the error, no luck. I delete the .babel.json, the error stiil comes out. I reinit a new project, still the same. I uninstall node.js and python, then install them again follow the "Getting Started" on RN mainpage, still the same. I install react-native-cli 2.0.1 and 1.3.0, still the same.

It seems the RN project works even with the error. But you never know when the error will hurt my project.

1
  • did you ever find the solution? I'm having the same issue Commented Mar 11, 2017 at 22:51

6 Answers 6

2

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 will post this into the related GitHub issue as well.

Sign up to request clarification or add additional context in comments.

1 Comment

1

Try deleting .babel.json, generate a new one and grant read permission to that file.

You have a babel.json file at C:\Users\Me 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.

https://github.com/facebook/react-native/issues/11803

  1. Delete .babel.json
  2. react-native run-android (re-generates .babel.json)
  3. open C:\Users\yourUserName\ in Windows Explorer (not IE)
  4. right click on .babel.json > Properties
  5. Security tab > Advanced > Change Permissions... > Add...
  6. Enter the object name to select, type Everyone, click OK
  7. Permissions window, tick "Allow Full Control", click OK
  8. click OK
  9. react-native run-android (works now)

Comments

1

My node.js's version was 7.5.0.

I updated it to 7.10.0 yesterday and the problem solved.

Comments

1

this worked for me:

react-native start --reset-cache

Comments

0

Try this line in git bush

chmod 777 .babel.json

The problem maybe that this file is read-only.

2 Comments

I did what you said. Still the same.
I meet this problem the other day and solve it by this way so I am sorry it doesn't works for you.If I find the right reason,I will commit it to you.
0

Remove the old version of app on your phone and then try this :

react-native start --reset-cache


npx react-native run-android

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.