react-native-firebase icon indicating copy to clipboard operation
react-native-firebase copied to clipboard

Unable to resolve "../../../../.."

Open steveacalabro-indevets opened this issue 1 year ago • 7 comments

Hi! 👋

I am creating a expo react native application using expo-router. Expo router has us using the metro bundler. When I simply add @react-native-firebase/analytics to the application I get the following error

Unable to resolve "../../../../.." from "node_modules/@react-native-firebase/analytics/lib/modular/index.js"
[DevIndeVets] Metro has encountered an error: While trying to resolve module `../../../../..` from file
`/Users/{my-user}/{my-git-folder-directory}/{my-project-name}/node_modules/@react-native-firebase/analytics/lib/modular/index.js`, the package
`/Users/{my-user}/{my-git-folder-directory}/{my-project-name}/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved
(`/Users/{my-user}/{my-git-folder-directory}/{my-project-name}/expo-router/entry`. Indeed, none of these files exist:

*
/Users/{my-user}/{my-git-folder-directory}/{my-project-name}/expo-router/entry(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.cjs|.native.cjs|.cjs|.ios.scss|.native.scss|.scss|.ios.sass|.native.sass|.sass|.ios.css|.native.css|.css|.ios.css|.native.css|.css|.ios.mjs|.native.mjs|.mjs)
* /Users/{my-user}/{my-git-folder-directory}/{my-project-name}/expo-router/entry/index(.native|.ios.ts|.nat<…>
› Stopped server
✨  Done in 68.49s.

I investigated the files used in the node_modules directory and was able to use patch-package to patch @react-native-firebase/[email protected]

Here is the diff that solved my problem:

diff --git a/node_modules/@react-native-firebase/analytics/lib/modular/index.js b/node_modules/@react-native-firebase/analytics/lib/modular/index.js
index 1b96573..bcb0f3f 100644
--- a/node_modules/@react-native-firebase/analytics/lib/modular/index.js
+++ b/node_modules/@react-native-firebase/analytics/lib/modular/index.js
@@ -1,4 +1,4 @@
-import { firebase } from '..';
+import { firebase } from '@react-native-firebase/app';
 
 /**
  * @typedef {import("..").FirebaseApp} FirebaseApp
@@ -648,15 +648,15 @@ export function isSupported() {
 }
 
 /**
- * Sets the applicable end user consent state for this app.
- * references once Firebase Analytics is initialized.
+ * Sets the applicable end user consent state for this web app across all gtag
+ * references once Firebase Analytics is initialized. Web only.
  * @param analytics Analytics instance.
  * @param consentSettings See {@link analytics.ConsentSettings}.
- * @returns {Promise<void>}
+ * @returns {void}
  */
 // eslint-disable-next-line
-export function setConsent(analytics, consentSettings) {
-  return analytics.setConsent(consentSettings);
+export function setConsent(consentSettings) {
+  // Returns nothing until Web implemented.
 }
 
 /**

As you can see changing

import { firebase } from '..';

To

import { firebase } from '@react-native-firebase/app';

will let it actually resolve. I'm worried I didn't configure thing correctly. Could this be an actual issue or just me?

steveacalabro-indevets avatar Apr 02 '24 16:04 steveacalabro-indevets

I was having a similar problem when migrating from react-navigation to expo-router.

This was caused by a fault in my babel.config.js I had defined the root as "./src" where my src/screens is but since expo router uses app/ from root level as it's entry point it wasn't able to find the entry point.

After changing babel.config.js I deleted the patches, removed and reinstalled node_modules, and ran yarn start --clear to clear the bundler. It seems to have resolved the issue for me.

Why this happens when using @react-native-firebase/analytics I'm more unsure of.

diff --git a/babel.config.js b/babel.config.js
index f8b0d586..e07b7372 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -6,7 +6,7 @@ module.exports = function (api) {
       [
         'module-resolver',
         {
-          root: ['./src'],
+          root: ['./'],
           extensions: ['.ios.js', '.android.js', '.js', '.ts', '.tsx', '.json'],
           alias: {
             '@src': './src',

bjornevik avatar Apr 12 '24 12:04 bjornevik

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar May 10 '24 14:05 github-actions[bot]

same issue

tandler5 avatar May 19 '24 13:05 tandler5

same issue

msasinowski avatar May 20 '24 16:05 msasinowski

same issue when i use package @react-native-firebase/messaging version 19.0.1

npv2k1 avatar May 22 '24 23:05 npv2k1

same issue

jervis446 avatar May 23 '24 23:05 jervis446

Hello 👋, to help manage issues we automatically close stale issues.

This issue has been automatically marked as stale because it has not had activity for quite some time.Has this issue been fixed, or does it still require attention?

This issue will be closed in 15 days if no further activity occurs.

Thank you for your contributions.

github-actions[bot] avatar Jun 20 '24 23:06 github-actions[bot]

Having the same issue too

thoth-seshat avatar Jul 16 '24 00:07 thoth-seshat

Same issue too

jonjts avatar Sep 07 '24 19:09 jonjts