facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.22k stars 626 forks source link

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

Open tkulpa opened 5 years ago

tkulpa commented 5 years ago
[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
}
tkulpa commented 5 years ago

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

Rendfold commented 5 years ago

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

asnewman commented 5 years ago

This is still an issue. Any updates?

Rendfold commented 5 years ago

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?

alexyazvinsky commented 4 years ago

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

juliarnasution commented 4 years ago

same issue, when require .png file in component

Rendfold commented 4 years ago

@juliarnasution is your image inside project?

juliarnasution commented 4 years ago

@Rendfold yes, but it has been solved

ntta commented 4 years ago

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.

SKrotkih commented 4 years ago

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

MustafaFahmy-FE commented 4 years ago

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

joe06102 commented 4 years ago

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

nichoga commented 4 years ago

@SKrotkih any progress? Having the same issue

diegovfeder commented 4 years ago

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 👍🏼