0

I cannot build the project for android. When ever I run the gradlew assembleRelease, I get the following error:

Failed to capture snapshot of input files for task ':app:bundleReleaseJsAndAsset s' property '$1' during up-to-date check.

Could not read path 'E:\React Native\IRStocks\node_modules\@babel\core\node_mo dules\json5.bin\json5'.

Here is my package.json:

"dependencies": {
    "@babel/core": "latest",
    "babel-core": "latest",
    "@babel/runtime": "^7.1.2",
    "axios": "^0.18.0",
    "babel-plugin-transform-decorators-legacy": "^1.3.5",
    "metro-react-native-babel-preset": "^0.49.0",
    "mobx": "4.3.1",
    "mobx-react": "5.1.0",
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-charts-wrapper": "^0.5.0",
    "react-native-device-info": "0.18.0",
    "react-native-draggable-flatlist": "^1.1.5",
    "react-native-orientation-locker": "^1.0.18",
    "react-navigation": "^2.17.0",
    "searchable-flatlist": "0.0.4"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "babel-preset-react-native": "^5",
    "jest": "23.6.0",
    "react-test-renderer": "16.3.1"
  },
  "jest": {
    "preset": "react-native"
  },

BTW:

Environment:
  OS: Windows 8.1
  Node: 8.11.2
  Yarn: 1.12.1
  npm: 6.1.0
  Watchman: Not Found
  Xcode: N/A
  Android Studio: Version  2.3.0.0 AI-162.3871768

Packages: (wanted => installed)
  react: 16.3.1 => 16.3.1
  react-native: 0.55.4 => 0.55.4

Any idea?

Inigo
  • 12,186
  • 5
  • 41
  • 70
MohamadKh75
  • 2,582
  • 5
  • 28
  • 54
  • This might be related to having multiple versions of babel installed – Kai Nov 01 '18 at 16:35
  • I removed all of them except but the problem is still there... – MohamadKh75 Nov 01 '18 at 16:37
  • If you delete `node_modules` and reinstall, does the error persist? – loganfsmyth Nov 01 '18 at 16:58
  • @loganfsmyth - yes! i delete that and run `yarn` but it's still have problem! – MohamadKh75 Nov 01 '18 at 16:58
  • I once had a somewhat similar problem when I first tested out `RN@0.57.3`. Try downloading this package: https://github.com/babel/babel-upgrade and then run the `babel-upgrade --write` command at the root of your project. Hope it helps. – Ray Nov 01 '18 at 21:47
  • Same issue here. When you go to 'E:\React Native\IRStocks\node_modules\@babel\core\node_mo dules\json5.bin' is json5 a ? – Christian Chown Nov 03 '18 at 11:23
  • yes! thats a shortcut :| – MohamadKh75 Nov 03 '18 at 13:18
  • I've solved this for my setup! The problem is that webpack (I think) is not respecting the symlinks (I don't actually think they should be JUNCTIONs), so I wrote a console app - gist here: https://gist.github.com/christianchown/62d929cf196cd8782635288bfeba6069 - that scans node_modules and replace junctions with real files. Message me if you'd like .exe rather than the source code in that gist – Christian Chown Nov 03 '18 at 14:50
  • Here's that gist as a repo: https://github.com/christianchown/nojunction - there's an .exe in there – Christian Chown Nov 03 '18 at 14:58
  • Thanks! Would you please add `.exe` in the repo? – MohamadKh75 Nov 03 '18 at 15:45
  • It's there already, `nojunction.exe` here: https://github.com/christianchown/nojunction/tree/master/bin/Debug – Christian Chown Nov 03 '18 at 22:39
  • Thanks! I used `npm install` instead of `yarn` and now it's working! – MohamadKh75 Nov 04 '18 at 11:05

2 Answers2

0

That was because of Yarn: 1.12.1 and it's solved when I upgraded to 1.12.3.

MohamadKh75
  • 2,582
  • 5
  • 28
  • 54
  • I'm tired to upgrade yarn to 1.12.3 but it's not upgraded idk why? what's the command you use to upgrade? – DevAS May 21 '19 at 02:40
  • I've uninstalled them from the control panel in Win and when i check the -v i see 1.16.0 so, when i run gradlew assembleRelease i Got https://stackoverflow.com/questions/56239244/cant-generating-the-release-apk-react-native/ – DevAS May 21 '19 at 13:25
0

I also encountered this. Seems to be a problem with newer Yarn versions on Windows.

I am using yarn version 1.12.1 and I got the same problem.

I have downgraded yarn version to 1.10.1 then it works!

Step by step:

  1. Uninstall yarn 1.12.1

  2. Install yarn 1.10.1

  3. Go to project folder and execute yarn install

  4. Build my project and the error is gone

Trọng Nguyễn Công
  • 1,207
  • 1
  • 10
  • 23