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

Error: Cannot resolve ./override #143

Open
5 of 7 tasks
quicksilverr opened this issue Jan 4, 2024 · 8 comments
Open
5 of 7 tasks

Error: Cannot resolve ./override #143

quicksilverr opened this issue Jan 4, 2024 · 8 comments

Comments

@quicksilverr
Copy link

quicksilverr commented Jan 4, 2024

Describe the bug

Hey, after importing config from react-native-ultimate-config, I'm getting this error

error: Error: Cannot resolve ./override
    at /project/node_modules/@nx/react-native/plugins/metro-resolver.js:31:15
    at Object.resolve (/ project/node_modules/metro-resolver/src/resolve.js:47:12)
    at ModuleResolver.resolveDependency (/ project/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:79:31)
    at DependencyGraph.resolveDependency ( /project/node_modules/metro/src/node-haste/DependencyGraph.js:277:43)
    at Object.resolve ( /project/node_modules/metro/src/lib/transformHelpers.js:169:21)
    at Graph._resolveDependencies ( /project/node_modules/metro/src/DeltaBundler/Graph.js:473:35)
    at Graph._processModule ( /project/node_modules/metro/src/DeltaBundler/Graph.js:261:38)
    at async Graph._addDependency ( /project/node_modules/metro/src/DeltaBundler/Graph.js:372:20)
    at async Promise.all (index 7)
    at async Graph._processModule (/ project/node_modules/metro/src/DeltaBundler/Graph.js:322:5)

Steps to Reproduce

  • Just install the package in a react native project, and import config from the package.
  • Getting the metro resolver error.

Steps to reproduce the behavior.

Please consider creating small project that demonstrates the problem.
Having done clean setup helps pinpointing the problem.

Expected behavior

This snippet should work

// import module
import config from "react-native-ultimate-config";

// access variables
config.MY_CONFIG;

Stacktraces, logs, screenshots

Post stacktraces, logs or screenshots. The more information is available
is better.

Environment

Integration option

  • I am using rnuc CLI to inject environment (default integration option
    from quickstart guide)
  • I am using scheme/flavor based integration (experimental integration
    option from cookbook:
    scheme,
    flavors)
  • I am using react-native-ultimate-config within monorepo managed with NX Monorepo

Env file

  • I am using dotenv file as a source for variables
  • I am using YAML file as a source for variables

Example of env file that is causing problems

❗PROVIDE EXAMPLE OF ENV FILE

OS

  • ios
  • android

Packages

  • version of react-native: ❗0.72.3
  • version of react-native-ultimate-config: ❗6.0.1

Run react-native info and post below:

System:
  OS: macOS 13.3
  CPU: (8) arm64 Apple M1
  Memory: 62.13 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 19.5.0
    path: /var/folders/w1/6fkl87mj5n9cmc_nk6xfsz7h0000gn/T/yarn--1704361025739-0.5088639990007069/node
  Yarn:
    version: 1.22.19
    path: /var/folders/w1/6fkl87mj5n9cmc_nk6xfsz7h0000gn/T/yarn--1704361025739-0.5088639990007069/yarn
  npm:
    version: 9.3.1
    path: ~/.nvm/versions/node/v19.5.0/bin/npm
  Watchman:
    version: 2023.05.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.11.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK:
    API Levels:
      - "23"
      - "28"
      - "29"
      - "30"
      - "31"
      - "33"
    Build Tools:
      - 28.0.3
      - 29.0.2
      - 30.0.2
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 34.0.0
    System Images:
      - android-31 | Google APIs ARM 64 v8a
      - android-31 | Google Play ARM 64 v8a
    Android NDK: 22.1.7171670
IDEs:
  Android Studio: 2020.3 AI-203.7717.56.2031.7678000
  Xcode:
    version: 14.3/14E222b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 1.8.0_292
    path: /usr/bin/javac
  Ruby:
    version: 3.2.2
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: "*"
  react-native:
    installed: 0.72.3
    wanted: "*"
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Additional context

Add any other context about the problem here.

@quicksilverr
Copy link
Author

There is no override file, which is being called in the index.js
If we check here, is there something I'm missing @maxkomarychev
https://github.com/maxkomarychev/react-native-ultimate-config/blob/master/packages/react-native-ultimate-config/index.js

@quicksilverr
Copy link
Author

After removing that import, it started working. Is the override related something to the web?

@vision1214
Copy link

Any fix for this or we will have to patch this?

@vision1214
Copy link

After removing that import, it started working. Is the override related something to the web?

@quicksilverr After removing that import only, it starts working for web as well.

@maxkomarychev can you please help here.

@tilucast
Copy link

tilucast commented Jan 24, 2024

Yep, there is no such file. In older versions, this file does indeed exist.
Im updating from version 3.4.2, and the file is there, and looks like this

const RN = require("react-native");

const IOS_DATA = {}

const ANDROID_DATA = {}

module.exports = {
}

Im not sure what this file is supposed to do.

@vagnerlandio
Copy link
Contributor

@quicksilverr @tilucast the .override file is not generated after running the command "rnuc .env"?

@tilucast
Copy link

@vagnerlandio Youre right actually. I dont know what happened. The file now is being generated after running rnuc.

@vagnerlandio
Copy link
Contributor

vagnerlandio commented Jan 24, 2024

@vagnerlandio Youre right actually. I dont know what happened. The file now is being generated after running rnuc.

Awesome.

@vision1214 override file is not compatible with web. For this case, you can create a file rnuc.rc in the project root directory with the following content.

module.exports = {
  js_override: false
};

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

4 participants