React-native 开发问题汇总

齐昊苍
2023-12-01

1. 入门网站

https://reactnative.dev/docs/getting-started

https://reactnative.cn/docs/getting-started

2. 更换npm国内源
a、临时使用
npm --registry https://registry.npm.taobao.org install express
 
b、持久使用 
npm config set registry https://registry.npm.taobao.org
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
// 配置后可通过下面方式来验证是否成功
npm config get registry
// 或
npm info express
c. 更换回官方源
npm config set registry https://registry.npmjs.org/

 

3. react-native run-andriod的时候,卡在Resolve dependencies of:
A. 除了第一次,以后都可以断网
2. 在项目>android>build.gradle添加如下加粗代码
allprojects {
    repositories {
        google(){ url 'https://maven.aliyun.com/repository/google' }
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }

        jcenter() { url 'https://maven.aliyun.com/repository/public' }
        

        // picker-image
        //maven { url 'https://maven.google.com' }
        maven { url 'https://maven.aliyun.com' }
        
        maven { url 'https://www.jitpack.io' }
    }
}

 类似资料: