Metro: ReferenceError: SHA-1 for file [(...).png] is not computed

Created on 18 May 2019  路  14Comments  路  Source: facebook/metro

[0] sha1 3aabc4bf20662c004fea1fc5fada45d88cb21c74 file [...]/src/parallaximage/ParallaxImage.js
[0] sha1 48bd39bdb03d630a2cb85c12c736d2fb74392609 file [...]/src/utils/animations.js
[0] sha1 1e735cdb78d49457628797acfbfcfdc958c9e0e9 file [...]/node_modules/react-native-svg/index.js
[0] sha1 null file [...]/assets/bitcoin-large.png
[0] sha1 null file [...]/assets/campaign-lime.png
[0] sha1 null file [...]/assets/campaign-orange.png
[0] sha1 null file [...]/assets/campaign-pink.png
[0] sha1 null file [...]/assets/campaign-cyan.png

output for:
console.log('sha1', sha1, 'file', filename)
at /node_modules/metro/src/node-haste/DependencyGraph.js:257

There is no sha1 generated for png and jpg files after react native upgrade, not sure how to fix that

rn-cli-config.js

// const path = require('path')
// const cwd = path.resolve(__dirname)

module.exports = {
  // transformer: {
  //   babelTransformerPath: path.resolve(__dirname, './config/transformers.js'),
  // },
  resolver: {
    sourceExts: ['jsx', 'js'],
    assetExts: ['png', 'jpg']
  },
  // projectRoot: cwd
}

Most helpful comment

What I did notice is that it happens if imported images are outside of your project and that is logical, that was my mistake.
I am using lerna and it happened a lot of times. Maybe it is your issue as well?

All 14 comments

it was related to project packager start command that was
yarn build:tsc && node_modules/.bin/concurrently 'react-native start' 'npm run copy -- --watch' 'npm run watch:tsc
after starting everything separately everything is fine
And it worked for react native 0.57 version and happens on 0.59.8

Actually, same happens on react native 0.60.4, without this command. Any suggestions?

This is still an issue. Any updates?

What I did notice is that it happens if imported images are outside of your project and that is logical, that was my mistake.
I am using lerna and it happened a lot of times. Maybe it is your issue as well?

same issue for fastlane release builds
/Users/.../Downloads/.../node_modules/metro/src/lib/polyfills/require.js (/Users/.../Downloads/.../node_modules/metro/src/lib/polyfills/require.js) is not computed

same issue, when require .png file in component

@juliarnasution is your image inside project?

@Rendfold yes, but it has been solved

I encounter the same issue. However, it has been resolved.
I have copied images to the project folder while the bundler was still running, so it didn't detect those new images. Just need to restart the bundler, everything will work fine.

same fatal issue with require.js
[fatal][tid:main] Metro has encountered an error: SHA-1 for file /usr/local/lib/node_modules/react-native/node_modules/metro/src/lib/polyfills/require.js (/usr/local/lib/node_modules/react-native/node_modules/metro/src/lib/polyfills/require.js) is not computed

My packages dependencies:
"dependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@babel/runtime": "^7.9.6",
"@react-native-community/eslint-config": "^1.1.0",
"@react-native-community/masked-view": "^0.1.10",
"@react-navigation/native": "^5.3.0",
"axios": "^0.18.1",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.0.1",
"babel-loader": "^8.1.0",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-react-transform": "^3.0.0",
"babel-preset-react-native": "^4.0.1",
"metro-react-native-babel-preset": "^0.59.0",
"react": "16.11.0",
"react-native": "0.62.2",

Please say where I missed.

I updated
npm install -i -g --force react-native-cli
made
yarn
and so on
the same issue on different computers

Try to change the name of the image file .. it helps me

make sure your directory name do not start with '.' , because globby will ignore the folder.

@SKrotkih any progress? Having the same issue

What I did notice is that it happens if imported images are outside of your project and that is logical, that was my mistake.
I am using lerna and it happened a lot of times. Maybe it is your issue as well?

Thanks! I was importing from (../../../etc) and when I changed the require to ./assets/ it worked 馃憤馃徏

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dlferro picture dlferro  路  5Comments

Naturalclar picture Naturalclar  路  4Comments

aleclarson picture aleclarson  路  4Comments

brentvatne picture brentvatne  路  4Comments

alexanderoskin picture alexanderoskin  路  5Comments