Home » Android » android – error: bundling failed: ReferenceError: SHA-1 for file index.js

android – error: bundling failed: ReferenceError: SHA-1 for file index.js

Posted by: admin June 15, 2020 Leave a comment

Questions:

react-native: 0.57.0
yarn : 1.9.4
nodejs: 9.10.1

react-native run-android give me this error:

[android, dev] ..\..\../index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1)::ffff:127.0.0.1 - - [14/Sep/2018:07:12:00 +0000] "GET /index.delta?platform=android&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.10.0"
error: bundling failed: ReferenceError: SHA-1 for file c:\wamp64\www\React\hello1\index.js is not computed
    at DependencyGraph.getSha1 (c:\wamp64\www\React\hello1\node_modules\metro\src\node-haste\DependencyGraph.js:238:119)
    at c:\wamp64\www\React\hello1\node_modules\metro\src\Bundler.js:168:56
    at Generator.next (<anonymous>)
    at step (c:\wamp64\www\React\hello1\node_modules\metro\src\Bundler.js:11:657)
    at c:\wamp64\www\React\hello1\node_modules\metro\src\Bundler.js:11:817
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)
How to&Answers:

That looks like an issue related to metro.

Try to close console and in the project folder run:

rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-* && watchman watch-del-all && rm -rf node_modules/ && npm install && npm start -- --reset-cache

then run
react-native run-android

For windows cleaning cache should be something like this:

del %appdata%\Temp\react-* & del %appdata%\Temp\metro-* & del %appdata%\Temp\haste-* & del node_modules & npm install & watchman watch-del-all & npm start -- --reset-cache
(I haven’t tried it on windows, probably for windows best option to remove node_modules would be to install rimraf)

If it still doesn’t work check package.json and .babelrc. You should have something like this:

"metro-react-native-babel-preset": "^0.45.0", and .babelrc configuration:

{
    "presets": ["module:metro-react-native-babel-preset"]
}

Answer:

I used

npm install
npm audit fix

and then on different consoles

npx react-native start

Answer:

i just try:

watchman watch-del-all && rm -rf node_modules/ && yarn install && yarn run dev

and in my case, i uninstall and reinstall my app on emulator, then it works