版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liqianglai/article/details/78882075
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
expo
在google 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