创建React Native的第一个hello world工程

创建React Native的第一个hello world工程

需要安装好node、npm环境

如果之前没有安装过react-native-cli脚手架的,可以按照下述步骤直接安装。如果已经安装过的,但是在使用这个脚手架初始化工程的时候遇到下述报错的话

ts 复制代码
cli.init(root, projectname);
      ^
typeerror: cli.init is not a function
    at run (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:302:7)
    at createproject (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:249:3)
    at init (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:200:5)
    at object.<anonymous> (c:\users\showbi\appdata\roaming\npm\node_modules\react-native-cli\index.js:153:7)
    at module._compile (node:internal/modules/cjs/loader:1105:14)
    at object.module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at module.load (node:internal/modules/cjs/loader:981:32)
    at function.module._load (node:internal/modules/cjs/loader:822:12)
    at function.executeuserentrypoint [as runmain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

也可以先直接卸载

ts 复制代码
npm uninstall -g react-native-cli

正常安装过程:

  1. 安装react-native-cli
ts 复制代码
npm install -g react-native-cli
  1. 安装react-native
ts 复制代码
npm install -g react-native

安装完成之后,可以用脚手架来初始化项目

TS 复制代码
npx react-native init firstRNProject

就会出现下述的界面

安装编译到Android手机上去

ts 复制代码
react-native run-android

启动以后的界面如下所示:

在这个过程中可能会遇到一些版本带来的问题,

相关推荐
云水一下11 小时前
从零开始!VMware安装Fedora Workstation 44桌面系统完整教程
前端
小码哥_常12 小时前
安卓黑科技:实现多平台商品详情页一键跳转APP
前端
killerbasd12 小时前
还是迷茫 5.3
前端·react.js·前端框架
不会敲代码113 小时前
TCP/IP 与前端性能:从数据包到首次渲染的底层逻辑
前端·tcp/ip
kyriewen13 小时前
奥特曼借GPT-5.5干杯,而你的Copilot正按Token收钱
前端·github·openai
AC赳赳老秦13 小时前
投标合规提效:用 OpenClaw 实现标书 / 合同自动审核、关键词校验、格式优化,降低废标风险
开发语言·前端·python·eclipse·emacs·deepseek·openclaw
kyriewen13 小时前
代码写成一锅粥?3个设计模式让你的项目“起死回生”
前端·javascript·设计模式
不会敲代码114 小时前
从零搭建 AI 日记助手:用 Milvus 向量数据库实现语义搜索
javascript·openai
千寻girling14 小时前
《 Git 详细教程 》
前端·后端·面试
threelab15 小时前
Three.js UV 图像变换效果 | 三维可视化 / AI 提示词
javascript·人工智能·uv