Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resolve "../../../../.." #7728

Open
steveacalabro-indevets opened this issue Apr 2, 2024 · 6 comments
Open

Unable to resolve "../../../../.." #7728

steveacalabro-indevets opened this issue Apr 2, 2024 · 6 comments

Comments

@steveacalabro-indevets
Copy link

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/analytics@19.1.1

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?

@bjornevik
Copy link

bjornevik commented Apr 12, 2024

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',

Copy link

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 github-actions bot added the Type: Stale Issue has become stale - automatically added by Stale bot label May 10, 2024
@tandler5
Copy link

same issue

@github-actions github-actions bot removed the Type: Stale Issue has become stale - automatically added by Stale bot label May 19, 2024
@msasinowski
Copy link

same issue

@npv2k1
Copy link

npv2k1 commented May 22, 2024

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

@jervis446
Copy link

same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants