美文网首页
1.ReactNative 学习笔记

1.ReactNative 学习笔记

作者: YFBigHeart | 来源:发表于2020-02-25 18:29 被阅读0次

    第一步环境搭建
    ReactNative Mac环境安装,转载自罗豪博客,也可以直接看官网的

    yarn 可以替代npm 使用,下面的连接是yarn 常用的命令(https://www.cnblogs.com/sunqq/p/10785445.html)

    高版本是需要pod 引入依赖,当出现以下报错的话可以尝试在Podfile文件第一行加上:

    source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
    

    () /* 报错内容 [!] CDN: trunk URL couldn't be downloaded: https://raw.githubusercontent.com/CocoaPods/Specs/master/Specs/6/7/d/boost-for-react-native/1.63.0/boost-for-react-native.podspec.json, error: Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443) */ ()

    image.png

    当Pod 安装好之后,运行起来如果遇到如下报错
    我的解决办法是在项目目录命令行执行下面两句命令

    npm uninstall react-native-progress
    npm install react-native-progress --save
    
    2020-02-25 17:53:18.481 [info][tid:main][RCTRootView.m:293] Running application AwesomeProject ({
        initialProps =     {
        };
        rootTag = 1;
    })
    2020-02-25 17:53:20.753 [fatal][tid:main] Unable to resolve module `react` from `App.js`: react could not be found within the project.
    
    If you are sure the module exists, try these steps:
     1. Clear watchman watches: watchman watch-del-all
     2. Delete node_modules: rm -rf node_modules and run yarn install
     3. Reset Metro's cache: yarn start --reset-cache
     4. Remove the cache: rm -rf /tmp/metro-*
    
    Simulator Screen Shot - iPhone 11 Pro Max - 2020-02-25 at 17.53.25.png

    相关文章

      网友评论

          本文标题:1.ReactNative 学习笔记

          本文链接:https://www.haomeiwen.com/subject/spqmaqtx.html