const account = new Account(client);
export const loginUser = async (email: string, password: string) => {
try {
const session = await account.createEmailPasswordSession(email, password); // error.
console.log('Login successful:', session);
return session;
} catch (error) {
console.error('Login error:', error);
throw error;
}
};
An error occurred when I used react native to integrate appwrite to implement user login.
ERROR Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'PlatformConstants' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes
ERROR Login error: [TypeError: Cannot read property 'OS' of undefined]
ERROR Login failed: [TypeError: Cannot read property 'OS' of undefined]
Strangely enough, it can be executed normally on the web end, but not on the app end.
{
"name": "xxx",
"main": "expo-router/entry",
"version": "1.0.0",
"scripts": {
"start": "expo start",
"reset-project": "node ./scripts/reset-project.js",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"test": "jest --watchAll",
"lint": "expo lint"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/vector-icons": "^14.0.2",
"@react-navigation/bottom-tabs": "^7.2.0",
"@react-navigation/native": "^7.0.14",
"expo": "^53.0.0",
"expo-auth-session": "^6.1.5",
"expo-blur": "~14.1.4",
"expo-constants": "~17.1.6",
"expo-font": "~13.3.1",
"expo-haptics": "~14.1.4",
"expo-linear-gradient": "~14.1.4",
"expo-linking": "~7.1.4",
"expo-router": "~5.0.6",
"expo-splash-screen": "~0.30.8",
"expo-status-bar": "~2.2.3",
"expo-symbols": "~0.4.4",
"expo-system-ui": "~5.0.7",
"expo-web-browser": "~14.1.6",
"lodash": "^4.17.21",
"nativewind": "^4.1.23",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-native": "0.79.2",
"react-native-appwrite": "^0.7.0",
"react-native-calendars": "^1.1311.1",
"react-native-gesture-handler": "~2.24.0",
"react-native-paper": "^5.13.5",
"react-native-reanimated": "~3.17.4",
"react-native-safe-area-context": "5.4.0",
"react-native-screens": "~4.10.0",
"react-native-svg": "15.11.2",
"react-native-url-polyfill": "^2.0.0",
"react-native-web": "^0.20.0",
"react-native-webview": "13.13.5",
"tailwindcss": "^3.4.17"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@types/jest": "^29.5.12",
"@types/react": "~19.0.0",
"@types/react-test-renderer": "^19.0.0",
"jest": "^29.2.1",
"jest-expo": "~53.0.5",
"react-test-renderer": "19.0.0",
"typescript": "^5.3.3"
},
"private": true
}
How should I solve this problem.
Description
An error occurred when I used react native to integrate appwrite to implement user login.
Strangely enough, it can be executed normally on the web end, but not on the app end.
Env
package.json
How should I solve this problem.