realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.62k stars 558 forks source link

Realm package path . is not exported - expo #6238

Closed martilopez closed 1 month ago

martilopez commented 6 months ago

I'm working on a react-native project with expo and i've come across this bug.

Whenever installing realm using:

expo init MyAwesomeRealmApp --template @realm/expo-template I get the following error:

`ERROR in ./app/AppWrapperSync.tsx:11 Module not found: Package path . is not exported from package C:\Users\marti\Desktop\TFG\Guaki\node_modules\realm (see exports field in C:\Users\marti\Desktop\TFG\Guaki\node_modules\realm\package.json) 9 | 10 | import {RealmProvider} from '@realm/react';

11 | import {OpenRealmBehaviorType, OpenRealmTimeOutBehavior} from 'realm'; 12 | 13 | export const AppWrapperSync: React.FC<{ 14 | appId: string;

ERROR in ./app/models/Task.ts:9 Module not found: Package path . is not exported from package C:\Users\marti\Desktop\TFG\Guaki\node_modules\realm (see exports field in C:\Users\marti\Desktop\TFG\Guaki\node_modules\realm\package.json) 7 | // for an example of this. 8 |

9 | import Realm from 'realm'; 10 | 11 | // To use a class as a Realm object type in Typescript with the @realm/babel-plugin plugin, 12 | // simply define the properties on the class with the correct type and the plugin will convert

ERROR in ./node_modules/@realm/react/dist/index.js 2:0-26 Module not found: Error: Package path . is not exported from package C:\Users\marti\Desktop\TFG\Guaki\node_modules\realm (see exports field in C:\Users\marti\Desktop\TFG\Guaki\node_modules\realm\package.json)

web compiled with 3 errors`

I've tried reinstalling realm, downgrading versions and creating a new project. Whatever i do the error shows up.

kneth commented 6 months ago

@martilopez Can you provide details about your Windows installation (architecture, version, node version, etc.)?

martilopez commented 6 months ago

Im using node version 21.1.0. My pc s x64 and is in version 22H2 of windows. This is my package.json file:

  "name": "guaki",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@expo/webpack-config": "^19.0.0",
    "@react-navigation/native": "^6.1.9",
    "@react-navigation/native-stack": "^6.9.17",
    "@realm/react": "^0.6.1",
    "expo": "~49.0.15",
    "expo-dev-client": "^2.4.12",
    "expo-linear-gradient": "~12.3.0",
    "expo-status-bar": "~1.6.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-i18next": "^13.3.1",
    "react-native": "0.72.6",
    "react-native-get-random-values": "^1.9.0",
    "react-native-web": "~0.19.6",
    "realm": "^12.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/react": "~18.2.14",
    "babel-plugin-module-resolver": "^5.0.0",
    "sharp-cli": "^4.1.1",
    "typescript": "^5.2.2"
  },
  "private": true
}

And this is the error im getting: ERROR in ./node_modules/@realm/react/dist/index.js 2:0-26 Module not found: Error: Package path . is not exported from package C:\Users\marti\Desktop\Guaki\node_modules\realm (see exports field in C:\Users\marti\Desktop\Guaki\node_modules\realm\package.json)

CallumBrocklehurst commented 5 months ago

I am getting this issue too while using WSL2 (or locally on windows)

ozanicre commented 4 months ago

Did anyone find the solution to this problem?

kneth commented 3 months ago

I am not sure if https://github.com/realm/realm-js/issues/6482#issuecomment-1943551791 is relevant here

nirinchev commented 1 month ago

Closing as stale.