我在使用时遇到错误react-native start
,捆绑程序错误是:
bundling failed: ReferenceError: SHA-1 for file /home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/lib/polyfills/require.js (/home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/lib/polyfills/require.js) is not computed
at DependencyGraph.getSha1 (/home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/node-haste/DependencyGraph.js:258:13)
at /home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:211:26
at Generator.next (<anonymous>)
at asyncGeneratorStep (/home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:46:24)
at _next (/home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:66:9)
at /home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:71:7
at new Promise (<anonymous>)
at /home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:63:12
at Transformer.transformFile (/home/suvodip/.nvm/versions/node/v8.17.0/lib/node_modules/react-native/node_modules/metro/src/DeltaBundler/Transformer.js:236:7)
自从我安装了这个错误react-native-camera
,我不知道这是否是真正的问题。我试过做rm -rf node_modules/ && yarn install && react-native start -- --reset-cache
,但没有奏效。这是我的顶级build.gradle
文件:
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
classpath("com.google.gms:google-services:4.0.2")
}
}
allprojects {
repositories {
....
google()
jcenter()
maven { url "https://maven.google.com" }
maven { url "https://www.jitpack.io" }
}
}
这是我的app level build.gradle
:
apply plugin: "com.android.application"
import com.android.build.OutputFile
....
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.google.firebase:firebase-analytics:17.2.2" // Firebase analytics
implementation 'com.google.firebase:firebase-core:17.0.0'
.....
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: "com.google.gms.google-services"