-
-
Notifications
You must be signed in to change notification settings - Fork 600
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest versions of Parse Server and the Parse JS SDK.
Issue Description
When using Parse JavaScript SDK in a React Native (Expo) project, the app fails to start due to an incompatible Node.js dependency.
The package at "node_modules\parse\lib\react-native\uuid.js" attempted to import the Node standard library module "crypto".
It failed because the native React runtime does not include the Node standard library.
...
5 | var uuid = require('crypto').randomUUID;
// app/_layout.tsx
import Parse from 'parse/react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
// -------------- init parse server -------------- //
Parse.setAsyncStorage(AsyncStorage);
Parse.initialize('my-app-id', 'xxx');
Parse.serverURL = 'http://10.0.2.2:8080' + '/parse';// metro.config.js
const { getDefaultConfig } = require('expo/metro-config');
/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);
config.resolver.unstable_enablePackageExports = false;
module.exports = config;NOTE: Not a duplicate of #2633.
The unstable_enablePackageExports: false workaround fixes the issue in Parse SDK ≤7.x, but no longer works in v8.0.0 due to the direct use of Node.js crypto.randomUUID() in lib/react-native/uuid.js.
Steps to reproduce
-
Clone the repository:
git clone https://github.com/tiavina-mika/react-native-parse-server-issue -
Install dependencies:
npm install -
Start the Expo development server:
npm start -
Choose Android or scan the QR code and open the app using Expo Go on a physical device.
-
Observe the error:
- An error appears in the terminal/console
- The same error is shown in Expo Go
Actual Outcome
The app fails to start. The following error is shown in the terminal and in Expo Go:
The package at "node_modules\parse\lib\react-native\uuid.js" attempted to import the Node standard library module "crypto". It failed because the native React runtime does not include the Node standard library.
Expected Outcome
The app should start normally in Expo Go without errors.
Environment
Server
- Parse Server version:
8.2.5 - Operating system:
Windows 11 - Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
Local
Database
- System (MongoDB or Postgres):
MongoDB - Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
MongoDB Atlas
Client
- Parse JS SDK version:
8.0.0
Logs
The package at "node_modules\parse\lib\react-native\uuid.js" attempted to import the Node standard library module "crypto".
It failed because the native React runtime does not include the Node standard library.
Learn more: https://docs.expo.dev/workflow/using-libraries/#using-third-party-libraries
3 | });
4 | exports.default = void 0;
> 5 | var uuid = require('crypto').randomUUID;
| ^
6 | var _default = exports.default = uuid;
Import stack:
node_modules\parse\lib\react-native\uuid.js
| import "crypto"
node_modules\parse\lib\react-native\InstallationController.js
| import "./uuid"
node_modules\parse\lib\react-native\Parse.js
| import "./InstallationController"
node_modules\parse\react-native.js
| import "./lib/react-native/Parse.js"
app\_layout.tsx
| import "parse/react-native"