deepin react-native 开发环境搭建,


      • Nodejs安装
      • Yarn安装
      • create-react-native-app
      • expo预览APP
      • 搭建过程二三事

Node.js安装

  • 下载安装包https://nodejs.org/zh-cn/
  • 安装
# 解压
tar xvf node-v8.9.3-linux-x64.tar.xz
# 复制到你喜欢的目录 ~/software/
mv node-v8.9.3-linux-x64 ~/software/
# 添加到全局
ln -s /home/ff/software/node-v8.9.3-linux-x64/bin/node /usr/local/bin/node
ln -s /home/ff/software/node-v8.9.3-linux-x64/bin/npm /usr/local/bin/npm
  • 验证
# 任意目录
node -v && npm -v
# 输出
v8.9.3
5.5.1

Yarn安装

  • 参照官网即可
  • 使用Yan代替npm可以加快依赖包的下载速度
  • Yarn npm设置淘宝镜像
yarn config set registry https://registry.npm.taobao.org
npm config set registry https://registry.npm.taobao.org

create-react-native-app

# 安装
yarn global add create-react-native-app
# 创建项目
create-react-native-app my-project
# 进入目录
cd my-project
# 启动服务
yarn start

expo预览APP

  • expogoogle play上,因此通过APKPure来安装
  • APKPure上安装expo
  • expo扫码预览APP

搭建过程二三事

  • yarn start启动提示
20:24:57: Unable to start server
  See https://git.io/v5vcn for more information, either install watchman or run the following snippet:
    sudo sysctl -w fs.inotify.max_user_instances=1024
    sudo sysctl -w fs.inotify.max_user_watches=12288
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  • /etc/sysctl.conf最后面添加下面两行,解决上面的提示
# gedit /etc/sysctl.conf
fs.inotify.max_user_instances=1024
fs.inotify.max_user_watches=12288
  • su用户第一次密码设置
# 按提示输入密码即可
sudu passwd
  • yarn global add xxx xxx 命令无效
# 添加环境变量
gedit ~/.bashrc
# 最后添加 yourName-你的名字
export PATH="$PATH:/home/yourName/.yarn/bin"
# 重启后验证
echo $PATH

相关内容

    暂无相关文章