我从npm移到纱线,出于某种原因,尽管我导入了反应库,但我无法识别它,但我得到了错误:
./src/App.js
Module not found: Can't resolve 'react-native' in '/var/react-projects/gymgains/src'
我删除package.json.lock,也是yarn.lock,然后再次尝试:
yarn
但没有解决问题。
这是我的软件包。
{
"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"运行它在浏览器中看到它并将其推入模拟器中测试它是否存在差异,这可能是React-nater在Web浏览器中不起作用的问题?任何想法如何解决这个问题?
谢谢
我有一些非常相似的问题:
找不到模块:无法解析"反应"
就我而言,它帮助我做
yarn add react-native-web
由于您没有安装该模块。您可以尝试一下。
您可以尝试npm install
并查看。我认为您的node_modules没有react-native
软件包。