Anonymous
Ошибка: «Не удалось зарегистрировать навигатор. Вы обернули свое приложение« NavigationContainer »?»
Сообщение
Anonymous » 11 авг 2025, 02:57
Я новичок в создании приложения, и у меня возникают проблемы с школьным проектом. Я настроил макет на основе вкладок, и моя структура проекта следует за новыми конвенциями Expo-Router (например, с использованием App/(Tabs)/_ Mayout.tsx ).
Однако, когда я запускаю приложение (с npx expo start-clear или npm run android ), i eep следующая ошибка: ), I apte следующая ошибка: i eep следующая ошибка: i eep следующая ошибка: i appe the npx expo или npm. />
не смог зарегистрировать навигатор. Вы обернули свое приложение с помощью 'navigationContainer'?
Код: Выделить всё
app/
├── _layout.tsx
├── (tabs)/
│ ├── _layout.tsx {
let iconName: keyof typeof Ionicons.glyphMap = "home-outline";
switch (route.name) {
case "index":
iconName = "home-outline"; // Home icon
break;
case "players":
iconName = "person-outline"; // Player icon
break;
case "fixtures":
iconName = "calendar-outline"; // Calendar icon
break;
case "standings":
iconName = "trophy-outline";
break;
case "dreamteam":
iconName = "football-outline";
break;
}
return ;
},
tabBarActiveTintColor: "#ffffff",
tabBarInactiveTintColor: "#ffcccc",
tabBarStyle: {
backgroundColor: "#E41B23", // Liverpool red
height: 60,
},
headerStyle: {
backgroundColor: "#E41B23", // Liverpool red
borderBottomWidth: 0, // Removes any white line
elevation: 0, // Removes shadow on Android
},
headerTintColor: "#ffffff",
headerTitle: () => (
router.push("/login")}
style={styles.authButton}
>
Login
router.push("/register")}
style={styles.authButton}
>
Register
),
headerTitleStyle: {
fontWeight: "bold",
},
})}
>
);
}
const styles = StyleSheet.create({
safeArea: {
flex: 1,
backgroundColor: "#E41B23", // Match the header background
},
headerContainer: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
width: "100%",
},
logo: {
width: 100,
height: 100,
},
authButtons: {
flexDirection: "row",
marginRight: 10,
},
authButton: {
marginLeft: 10,
padding: 8,
backgroundColor: "#ffffff",
borderRadius: 5,
},
authButtonText: {
color: "#E41B23",
fontWeight: "bold",
},
});
и my package.json :
Код: Выделить всё
{
"name": "project_mobile_dev",
"version": "1.0.0",
"private": true,
"main": "expo-router/entry",
"license": "0BSD",
"scripts": {
"dev:client": "expo start",
"dev:server": "ts-node server/server.ts",
"start": "concurrently \"npm run dev:server\" \"npm run dev:client\"",
"android": "concurrently \"npm run server\" \"expo start --clear --android\"",
"ios": "expo run:ios",
"web": "expo start --web",
"test": "jest --watchAll",
"lint": "eslint ./",
"lint-fix": "eslint ./ --fix",
"format": "prettier --write ./",
"server": "ts-node server/server.ts",
"server:dev": "nodemon --watch 'server/**/*.ts' --exec 'ts-node' server/server.ts",
"dev": "ts-node server.ts",
"build": "npm run build:server && npm run build:web",
"build:server": "tsc",
"build:web": "expo export --platform web"
},
"dependencies": {
"@expo/vector-icons": "14.0.2",
"@react-native-async-storage/async-storage": "^1.21.0",
"@react-navigation/bottom-tabs": "^7.4.2",
"@react-navigation/native": "^7.1.14",
"@react-navigation/native-stack": "^7.3.21",
"@supabase/supabase-js": "^2.47.10",
"ajv": "^8.17.1",
"axios": "^1.7.9",
"browserify-fs": "^1.0.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"cors": "^2.8.5",
"crypto-browserify": "^3.12.1",
"expo": "~50.0.20",
"expo-router": "3.4.10",
"express": "^4.21.2",
"http-browserify": "^1.7.0",
"https-browserify": "^1.0.0",
"node-libs-react-native": "^1.2.1",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.73.6",
"react-native-gesture-handler": "~2.14.1",
"react-native-pager-view": "^6.2.3",
"react-native-reanimated": "~3.6.3",
"react-native-safe-area-context": "^4.8.2",
"react-native-screens": "^4.12.0",
"react-native-sqlite-storage": "^6.0.1",
"react-native-web": "^0.19.13",
"react-native-webview": "^13.6.4",
"sharp": "^0.33.5",
"stream-browserify": "^3.0.0",
"tls-browserify": "^0.2.2",
"tty-browserify": "^0.0.1",
"xmlbuilder": "^15.1.1"
},
"devDependencies": {
"@babel/core": "7.25.2",
"@expo/webpack-config": "^19.0.1",
"@types/axios": "^0.14.4",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/node": "^22.10.5",
"@types/react": "^18.2.45",
"@types/react-native-sqlite-storage": "^6.0.5",
"@types/react-test-renderer": "18.3.0",
"concurrently": "^9.1.2",
"eslint": "9.13.0",
"eslint-config-expo": "8.0.1",
"eslint-plugin-react": "7.37.2",
"eslint-plugin-react-hooks": "5.0.0",
"jest": "29.7.0",
"jest-expo": "^50.0.1",
"nodemon": "^3.1.9",
"prettier": "3.3.3",
"ts-node": "^10.9.2",
"typescript": "^5.7.2",
"webpack": "^5.97.1",
"webpack-cli": "^6.0.1"
}
}
< /code>
Что я попробовал < /h3>
[list]
[*]app/(tabs)/_layout.tsx только использует (без контейнера)
[*] обновляемый/пониженная экспозиция (та же ошибка)
[*] npx expo-doctor и фиксированные проблемы configfile codefile
[*] expo-core-core-core-core-core-core-core-core-core-core-core-core-corodul Expo-Modules-Autoliking From Package.json
[*] Установил все с помощью:
[/list]
Remove-Item -Force .\package-lock.json
npm cache clean --force
npm install --legacy-peer-deps
< /code>
Если кто -то мог бы помочь мне решить это, я бы очень признателен. Заранее спасибо!
Подробнее здесь:
https://stackoverflow.com/questions/797 ... th-navigat
1754870233
Anonymous
Я новичок в создании приложения, и у меня возникают проблемы с школьным проектом. Я настроил макет на основе вкладок, и моя структура проекта следует за новыми конвенциями Expo-Router (например, с использованием App/(Tabs)/_ Mayout.tsx ). Однако, когда я запускаю приложение (с npx expo start-clear или npm run android ), i eep следующая ошибка: ), I apte следующая ошибка: i eep следующая ошибка: i eep следующая ошибка: i appe the npx expo или npm. /> не смог зарегистрировать навигатор. Вы обернули свое приложение с помощью 'navigationContainer'?[code]app/ ├── _layout.tsx ├── (tabs)/ │ ├── _layout.tsx { let iconName: keyof typeof Ionicons.glyphMap = "home-outline"; switch (route.name) { case "index": iconName = "home-outline"; // Home icon break; case "players": iconName = "person-outline"; // Player icon break; case "fixtures": iconName = "calendar-outline"; // Calendar icon break; case "standings": iconName = "trophy-outline"; break; case "dreamteam": iconName = "football-outline"; break; } return ; }, tabBarActiveTintColor: "#ffffff", tabBarInactiveTintColor: "#ffcccc", tabBarStyle: { backgroundColor: "#E41B23", // Liverpool red height: 60, }, headerStyle: { backgroundColor: "#E41B23", // Liverpool red borderBottomWidth: 0, // Removes any white line elevation: 0, // Removes shadow on Android }, headerTintColor: "#ffffff", headerTitle: () => ( router.push("/login")} style={styles.authButton} > Login router.push("/register")} style={styles.authButton} > Register ), headerTitleStyle: { fontWeight: "bold", }, })} > ); } const styles = StyleSheet.create({ safeArea: { flex: 1, backgroundColor: "#E41B23", // Match the header background }, headerContainer: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", width: "100%", }, logo: { width: 100, height: 100, }, authButtons: { flexDirection: "row", marginRight: 10, }, authButton: { marginLeft: 10, padding: 8, backgroundColor: "#ffffff", borderRadius: 5, }, authButtonText: { color: "#E41B23", fontWeight: "bold", }, }); [/code] и my package.json : [code]{ "name": "project_mobile_dev", "version": "1.0.0", "private": true, "main": "expo-router/entry", "license": "0BSD", "scripts": { "dev:client": "expo start", "dev:server": "ts-node server/server.ts", "start": "concurrently \"npm run dev:server\" \"npm run dev:client\"", "android": "concurrently \"npm run server\" \"expo start --clear --android\"", "ios": "expo run:ios", "web": "expo start --web", "test": "jest --watchAll", "lint": "eslint ./", "lint-fix": "eslint ./ --fix", "format": "prettier --write ./", "server": "ts-node server/server.ts", "server:dev": "nodemon --watch 'server/**/*.ts' --exec 'ts-node' server/server.ts", "dev": "ts-node server.ts", "build": "npm run build:server && npm run build:web", "build:server": "tsc", "build:web": "expo export --platform web" }, "dependencies": { "@expo/vector-icons": "14.0.2", "@react-native-async-storage/async-storage": "^1.21.0", "@react-navigation/bottom-tabs": "^7.4.2", "@react-navigation/native": "^7.1.14", "@react-navigation/native-stack": "^7.3.21", "@supabase/supabase-js": "^2.47.10", "ajv": "^8.17.1", "axios": "^1.7.9", "browserify-fs": "^1.0.0", "browserify-zlib": "^0.2.0", "buffer": "^6.0.3", "cors": "^2.8.5", "crypto-browserify": "^3.12.1", "expo": "~50.0.20", "expo-router": "3.4.10", "express": "^4.21.2", "http-browserify": "^1.7.0", "https-browserify": "^1.0.0", "node-libs-react-native": "^1.2.1", "os-browserify": "^0.3.0", "path-browserify": "^1.0.1", "react": "18.2.0", "react-dom": "18.2.0", "react-native": "0.73.6", "react-native-gesture-handler": "~2.14.1", "react-native-pager-view": "^6.2.3", "react-native-reanimated": "~3.6.3", "react-native-safe-area-context": "^4.8.2", "react-native-screens": "^4.12.0", "react-native-sqlite-storage": "^6.0.1", "react-native-web": "^0.19.13", "react-native-webview": "^13.6.4", "sharp": "^0.33.5", "stream-browserify": "^3.0.0", "tls-browserify": "^0.2.2", "tty-browserify": "^0.0.1", "xmlbuilder": "^15.1.1" }, "devDependencies": { "@babel/core": "7.25.2", "@expo/webpack-config": "^19.0.1", "@types/axios": "^0.14.4", "@types/cors": "^2.8.17", "@types/express": "^5.0.0", "@types/node": "^22.10.5", "@types/react": "^18.2.45", "@types/react-native-sqlite-storage": "^6.0.5", "@types/react-test-renderer": "18.3.0", "concurrently": "^9.1.2", "eslint": "9.13.0", "eslint-config-expo": "8.0.1", "eslint-plugin-react": "7.37.2", "eslint-plugin-react-hooks": "5.0.0", "jest": "29.7.0", "jest-expo": "^50.0.1", "nodemon": "^3.1.9", "prettier": "3.3.3", "ts-node": "^10.9.2", "typescript": "^5.7.2", "webpack": "^5.97.1", "webpack-cli": "^6.0.1" } } < /code> Что я попробовал < /h3> [list] [*]app/(tabs)/_layout.tsx[/code] [b] только использует [/b] (без контейнера) [*] обновляемый/пониженная экспозиция (та же ошибка) [*] npx expo-doctor и фиксированные проблемы configfile codefile [*] expo-core-core-core-core-core-core-core-core-core-core-core-core-corodul Expo-Modules-Autoliking From Package.json [*] Установил все с помощью: [/list] Remove-Item -Force .\package-lock.json npm cache clean --force npm install --legacy-peer-deps < /code> Если кто -то мог бы помочь мне решить это, я бы очень признателен. Заранее спасибо! Подробнее здесь: [url]https://stackoverflow.com/questions/79703880/error-couldnt-register-the-navigator-have-you-wrapped-your-app-with-navigat[/url]