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 "@metaplex-foundation/umi/serializers" from "node_modules/@metaplex-foundation/mpl-bubblegum/dist/src/hash.js" #94

Open
mordonez-me opened this issue Oct 28, 2023 · 7 comments

Comments

@mordonez-me
Copy link

mordonez-me commented Oct 28, 2023

No clue about what is going here...

Libraries

"@metaplex-foundation/umi": "^0.8.9",
"@metaplex-foundation/umi-bundle-defaults": "^0.8.9",
"@metaplex-foundation/umi-serializers": "^0.8.9",
"@metaplex-foundation/umi-web3js-adapters": "^0.8.9",

Code:
image

Stacktrace:

Unable to resolve module @metaplex-foundation/umi/serializers from FULLPATH/node_modules/@metaplex-foundation/mpl-bubblegum/dist/src/hash.js: @metaplex-foundation/umi/serializers could not be found within the project or in these directories:
  node_modules/@metaplex-foundation/mpl-bubblegum/node_modules
  node_modules
  2 | Object.defineProperty(exports, "__esModule", { value: true });
  3 | exports.hashMetadataCreators = exports.hashMetadataData = exports.hashMetadata = exports.hashLeaf = exports.hash = void 0;
> 4 | const serializers_1 = require("@metaplex-foundation/umi/serializers");
    |                                ^
  5 | const sha3_1 = require("@noble/hashes/sha3");
  6 | const generated_1 = require("./generated");
  7 | const leafAssetId_1 = require("./leafAssetId");

@mordonez-me
Copy link
Author

This is everywhere

image

@gmferraz
Copy link

@mordonez-me any updates? Facing the same issue

@mordonez-me
Copy link
Author

I just patched everywhere
image

Could you let me know if you found the error? I can try again if it's fixed, lmk.

@truongezgg
Copy link

I got the same error when trying to test my module by use jest. But it work with ts-node

ts-node metadata.spec.ts (success)
npm run test medata.spec.ts (Unable to resolve "@metaplex-foundation/umi/serializers" from...)

@Michaelsulistio
Copy link

Michaelsulistio commented Mar 21, 2024

Ran into this issue on React Native and after some investigation might have found the root cause.

Cause

This issue is caused because the @metaplex-foundation/umi package uses Package Exports to export the umi/serializers submodule.

React Native's Metro Bundler doesn't support Package Exports by default, so it is unable to find umi/serializers. Currently, Package Exports are an experimental feature in Metro and can be enabled following this guide.

Attempted fix

Following the guide, I enabled the experimental unstable_enablePackageExports flag, which actually fixed the issues with @metaplex-foundation/umi/serializers and the bundler was able to find it.

This is what I added to metro.config.js:

module.exports = {
  ...
  resolver: {
    unstable_enablePackageExports: true,
    unstable_conditionNames: ['types', 'require', 'import'],
  },

But it ran into another issue when trying to resolve an import within umi-bundle-defaults.

Error: Unable to resolve module ./plugin from /Users/mikesulistio/testing/umi-testing/UmiTestRN/node_modules/@metaplex-foundation/umi-bundle-defaults/dist/types/index.d.ts: 

@nhanphan
Copy link
Contributor

enabling the unstable_enablePackageExports without specifying unstable_conditionNames made my test app build.

module.exports = {
  ...
  resolver: {
    unstable_enablePackageExports: true,
  },

Find the bare bones app that can build here. NOTE: the button doesn't actually create an asset since it's expecting crypto to be there but the imports seem to be working as expected

@MarkSackerberg
Copy link
Contributor

As an additional workaround for node.js express @gin on Discord shared that this worked for them:

const moduleAlias = require('module-alias');
moduleAlias.addAlias('@metaplex-foundation/umi/serializers', '@metaplex-foundation/umi-serializers');

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