gpt4 book ai didi

reactjs - 找不到模块 : Can't resolve 'react-native'

转载 作者:行者123 更新时间:2023-12-05 07:25:23 26 4
gpt4 key购买 nike

我从 npm 转移到 yarn 并且出于某种原因,尽管我导入了 react-native 库但它无法识别它,我得到了错误:

./src/App.js
Module not found: Can't resolve 'react-native' in '/var/react-projects/gymgains/src'

我删除了 package.json.lock,还有 yarn.lock 并再次尝试:

yarn

但还是没有解决问题。

这是我的 package.json:

{
"name": "App",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react-firebase-file-uploader": "^2.4.2",
"react-native": "^0.58.5",
"react-native-cli": "^2.0.1",
"react-scripts": "2.1.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}

这是我的导入语句:

import React, { Component } from 'react';
import firebase from 'firebase';
import { Text, View, Image } from 'react-native';
import 'firebase/firestore';
import FileUploader from 'react-firebase-file-uploader';

使用'yarn start'运行它在浏览器中看到它和将它推送到Android以在模拟器中测试它之间是否有区别,这可能是react-native在网络浏览器中不起作用的问题?知道如何解决这个问题吗?

谢谢

最佳答案

我有一些非常相似的问题:

Module not found: Can't resolve 'react-native'

就我而言,它帮助我做到了

yarn add react-native-web

因为你没有安装那个模块。你可以试一试。

关于reactjs - 找不到模块 : Can't resolve 'react-native' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54843886/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com