ReactNative开始

2020-01-09  本文已影响0人  呦释原点

1. 项目初始化:

参考: https://reactnative.cn/docs/getting-started.html

问题1. EACCES: permission denied, open '/Users/mac/.npm。。。。。'

权限不允许
sudo chown -R $(whoami) ~/.npm
参考

问题2.

error Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template. Please try again manually: "cd ./demo01/ios && pod install".

[!] 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)
cocoapods 1.8+强制安装了新的源trunk,采用cdn替换了原本的master
可更新cocoapods解决
参考

2. react-native错误

  1. 运行iOS报错No bundle URL present
    Make sure you’re running a packager server or have included a .jsbundle file in your application bundle
    方案:我的解决办法, 用Xcode打卡这个项目就好了

  2. RN中方法的形式
    错: _onTouchFn (color) {}
    对: _onTouchFn = (color) => {}
    绑定this onPress={this._onTouchFn.bind(this)}
    绑定this并传参 onPress={this._onTouchFn.bind(this,参数1)}

  3. react-native项目启动时报错:Module AppRegistry is not registered callable module (calling runApplication)
    方案:1: 结束所有node进程;( Mac OS系统下可执行 killall -9 node,windows请自行查找)
    2: npm start;
    3: react-native run-ios 或者 react-native run-android;

上一篇下一篇

猜你喜欢

热点阅读