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

[Bug]: Unable to resolve module @ledgerhq/domain-service/signers/index #6173

Open
iGroza opened this issue Feb 13, 2024 · 8 comments
Open

[Bug]: Unable to resolve module @ledgerhq/domain-service/signers/index #6173

iGroza opened this issue Feb 13, 2024 · 8 comments
Labels
bug Something isn't working libraries Impacts the Libraries triage In need of triage

Comments

@iGroza
Copy link

iGroza commented Feb 13, 2024

Impacted Library name

@ledgerhq/hw-app-eth

Impacted Library version

6.35.4

Describe the bug

Error durning initialisation:

Error: Unable to resolve module @ledgerhq/domain-service/signers/index from /Users/..../node_modules/@ledgerhq/hw-app-eth/lib/services/ledger/index.js: @ledgerhq/domain-service/signers/index could not be found within the project or in these directories:
  node_modules
  13 | const logs_1 = require("@ledgerhq/logs");
  14 | const abi_1 = require("@ethersproject/abi");
> 15 | const index_1 = require("@ledgerhq/domain-service/signers/index");
     |                          ^
  16 | const erc20_1 = require("./erc20");
  17 | const contracts_1 = require("./contracts");
  18 | const nfts_1 = require("./nfts");

Expected behavior

initialisation without error

Additional context

"dependencies": {
  "@ledgerhq/hw-app-eth": "6.35.4",
  "@ledgerhq/hw-transport": "6.30.3",
  "@ledgerhq/react-native-hw-transport-ble": "6.32.2"
 }
@iGroza iGroza added bug Something isn't working libraries Impacts the Libraries triage In need of triage labels Feb 13, 2024
@bobo2018cp
Copy link

image I have the same problem!

@iGroza
Copy link
Author

iGroza commented Mar 20, 2024

Fixed by adding custom resolveRequest inside my metro.config.js config.

const path = require("path");
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
const defaultModuleResolver = getDefaultConfig(__dirname).resolver.resolveRequest;

const config = {
  // your other option here
  // ...
  resolver: {
    resolveRequest: (context, moduleName, platform) => {
      try {
        return context.resolveRequest(context, moduleName, platform);
      } catch (error) {
        console.warn('\n1️⃣ context.resolveRequest cannot resolve: ', moduleName);
      }

      try {
        const resolution = require.resolve(moduleName, {
          paths: [path.dirname(context.originModulePath), ...config.resolver.nodeModulesPaths],
        });

        if (path.isAbsolute(resolution)) {
          return {
            filePath: resolution,
            type: "sourceFile",
          };
        }
      } catch (error) {
        console.warn('\n2️⃣ require.resolve cannot resolve: ', moduleName);
      }

      try {
        return defaultModuleResolver(context, moduleName, platform);
      } catch (error) {
        console.warn('\n3️⃣ defaultModuleResolver cannot resolve: ', moduleName);
      }

      try {
        return {
          filePath: require.resolve(moduleName),
          type: "sourceFile",
        };
      } catch (error) {
        console.warn('\n4️⃣ require.resolve cannot resolve: ', moduleName);
      }

      try {
        const resolution = getDefaultConfig(require.resolve(moduleName)).resolver?.resolveRequest
        return resolution(context, moduleName, platform);
      } catch (error) {
        console.warn('\n5️⃣ getDefaultConfig cannot resolve: ', moduleName);
      }
    },
  },
};

module.exports = mergeConfig(getDefaultConfig(__dirname), config);

@iGroza iGroza closed this as completed Mar 20, 2024
@bobo2018cp
Copy link

image "I followed the configuration steps and obtained this result."

@live-github-bot
Copy link
Contributor

@bobo2018cp you are not part of the organization, please contact a maintainer if you need to run this command.

3 similar comments
@live-github-bot
Copy link
Contributor

@bobo2018cp you are not part of the organization, please contact a maintainer if you need to run this command.

@live-github-bot
Copy link
Contributor

@bobo2018cp you are not part of the organization, please contact a maintainer if you need to run this command.

@live-github-bot
Copy link
Contributor

@bobo2018cp you are not part of the organization, please contact a maintainer if you need to run this command.

@KVNLS
Copy link
Member

KVNLS commented Apr 16, 2024

Hello @iGroza, where do you have this error, please? Directly on Ledger Live or on another project?
Currently, we have issues with symlinks + React Native, this is solved on the latest react native version 0.73 (https://reactnative.dev/blog/2023/12/06/0.73-debugging-improvements-stable-symlinks#stable-symlink-support-in-metro) I'm working on the upgrade here #6596 and it works well.
Moreover, we don't export correctly our modules if you look at the package.json of @ledgerhq/domain-service. I would not recommend adding a custom resolver by yourself as it can lead to issues upgrading to a new version and maintaining it.
If you are trying to consume this module in another project I think that we could provide a fix by explicitly exporting this module in the package.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libraries Impacts the Libraries triage In need of triage
Projects
None yet
Development

No branches or pull requests

3 participants