reactjs - 无法在我的项目中解析“react-native”
问题描述
我从 React 官方网站制作了教程小项目,当我尝试使用一些本机反应组件(如 Text 和 ImageBackground)时,我得到以下编译错误:
未找到模块:无法在...中解析“react-native”
我用“npx create-react-app”创建了我的项目。
我所做的导入。
import { Text, ImageBackground } from 'react-native'
我尝试做 npm install 和 npm install 'react-native-elements' 等等......没有任何效果。
无论如何,这是我的 package.json:
{
"name": "tutorial",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
有任何想法吗?
解决方案
对于 React Native 移动应用程序
使用此命令创建 react 原生项目 android 和 ios 应用程序。
npx react-native init AwesomeProject
你还需要一些其他配置来运行这个项目,比如 node.js、android studio、android sdk 和 xcode for ios。您可以点击此链接了解更多详情。
https://facebook.github.io/react-native/docs/getting-started
对于 React Web 应用程序
npx create-react-app
上面的命令用于响应本机 Web 应用程序。
推荐阅读
- google-bigquery - BigQuery + PlayStore +Apps 历史数据
- javascript - 为没有 HTML 的 webpack mini-css-extract-plugin 提取文件创建链接标签
- javascript - 刮除和绕过 sucuri 保护的问题
- angular - 如何在 Angular 7 中设置/分配文件以形成文件输入
- ios - UICollectionView 顶部单元格在动画键盘外观时消失
- elasticsearch - TShark 的 Elasticsearch 映射
- git - 如何将 Gerrit 3.0 项目从一台 Gerrit 3.0 服务器迁移到另一台 Gerrit 3.0 服务器并维护更改元数据?
- ios - 如何将我设备上的移动应用程序转换为 IPA 文件?
- ruby-on-rails - Rails Admin - 对标签执行多重搜索
- sql - 用 SAS 语言在几秒钟内转换 hh:mm:ss 格式?