Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)
like image 910
Enis Ismaili Avatar asked Sep 14 '18 07:09

Enis Ismaili


4 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"]
}
like image 135
Florin Dobre Avatar answered Oct 21 '22 05:10

Florin Dobre


mac users: open terminal and follow:

1.npm uninstall -g react-native-cli

2.cd 3.cd .npm-global 4.cd bin 5.rm -rf react-native

6.npm install -g react-native-cli

Notice: if you are a Windows user go to your user folder and delete "react-native" folder instead of steps 2..5

like image 21
ItSNeverLate Avatar answered Oct 21 '22 04:10

ItSNeverLate


I used

npm install
npm audit fix

and then on different consoles

npx react-native start
like image 33
Gil Avatar answered Oct 21 '22 05:10

Gil


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

like image 45
SONGJP Avatar answered Oct 21 '22 03:10

SONGJP