当我要执行命令expo start时,给我以下错误,我开始使用react native,但我管理不多,这可能是什么?
app.json
{
"expo": {
"name": "Project",
"slug": "Project",
"version": "1.0.0",
"orientation": "portrait",
"sdkVersion": "35.0.0",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"web": {
"favicon": "./assets/favicon.png"
}
}
}
package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "^35.0.0",
"react": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"expo-status-bar": "^1.0.2",
"react-dom": "~16.11.0",
"react-native-web": "~0.11.7"
},
"devDependencies": {
"@babel/core": "^7.8.6",
"babel-preset-expo": "~8.1.0"
},
"private": true
}
新错误
我更改了文件夹中的文件
\ node_modules \ metro-config \ src \ defaults \ blacklist.js
在
var sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
为
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
现在出现此错误
最后一个错误是通过直接在模拟器上安装expo来解决的。
答案 0 :(得分:0)
如错误所示,未安装React Native
。所以,
(1)npm install
(2)npm start
就是这样。如果仍然有问题,请通过包含app.json
文件内容来更新您的问题。
更新:
我认为问题出在您的sdk
版本上。请尝试更改sdk
版本的版本。
(1)用以下内容替换package.json
。 (复制和粘贴)
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"expo": "~37.0.3",
"expo-status-bar": "^1.0.2",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
"react-native-web": "~0.11.7"
},
"devDependencies": {
"@babel/core": "^7.8.6",
"babel-preset-expo": "~8.1.0"
},
"private": true
}
上面,我将sdk
的版本从38
更改为37
。
(2)删除node_module
和.expo
文件夹(如果它们已在项目根目录中创建)。
(3)npm install
(4)npm start
就是这样。现在应该可以了!
答案 1 :(得分:0)
尝试通过更改以下行来更改package.json中的react-native的来源:
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
为此
"react-native": "^0.63.0",