anza-xyz / wallet-adapter

Modular TypeScript wallet adapters and components for Solana applications.
https://anza-xyz.github.io/wallet-adapter/
Apache License 2.0
1.55k stars 944 forks source link

Module not found: Can't resolve '@ngraveio/bc-ur' #909

Closed rlisac closed 7 months ago

rlisac commented 7 months ago

hello everyone

I am currently developing a new page and have recently received the following error message:

./node_modules/.pnpm/@keystonehq+bc-ur-registry@0.5.5/node_modules/@keystonehq/bc-ur-registry/dist/Decoder/index.js:4:16 Module not found: Can't resolve '@ngraveio/bc-ur'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module: ./node_modules/.pnpm/@keystonehq+bc-ur-registry@0.5.5/node_modules/@keystonehq/bc-ur-registry/dist/index.js ./node_modules/.pnpm/@keystonehq+sol-keyring@0.3.1/node_modules/@keystonehq/sol-keyring/dist/sol-keyring.cjs.development.js ./node_modules/.pnpm/@keystonehq+sol-keyring@0.3.1/node_modules/@keystonehq/sol-keyring/dist/index.js ./nodemodules/.pnpm/@solana+wallet-adapter-keystone@0.1.12@solana+web3.js@1.90.0/node_modules/@solana/wallet-adapter-keystone/lib/esm/adapter.js ./nodemodules/.pnpm/@solana+wallet-adapter-keystone@0.1.12@solana+web3.js@1.90.0/node_modules/@solana/wallet-adapter-keystone/lib/esm/index.js ./nodemodules/.pnpm/@solana+wallet-adapter-wallets@0.19.27@babel+runtime@7.24.0_@solana+web3.js@1.90.0_bs58@4.0._ippf7guhaaiva42ay32utmn2hy/node_modules/@solana/wallet-adapter-wallets/lib/esm/index.js ./components/ConnectWallet.jsx ./components/Header.js

Do you have any idea why this could be?

Bildschirmfoto 2024-03-01 um 15 36 16

Thank you very much for a short feedback.

ChetanXpro commented 7 months ago

I'm facing the same bug. Everything was working fine, but today, suddenly, I encountered this bug.

Screenshot 2024-03-01 at 10 28 31 PM
mcintyre94 commented 7 months ago

Hmm I'm not able to reproduce this. I created a new project and ran:

$ npm install --save \
    @solana/wallet-adapter-base \
    @solana/wallet-adapter-react \
    @solana/wallet-adapter-react-ui \
    @solana/wallet-adapter-wallets \
    @solana/web3.js \
    react

And all installed with no errors.

This @ngrave-io/bc-ur package is included in those dependencies:

$ grep 'bc-ur' package-lock.json
    "node_modules/@keystonehq/bc-ur-registry": {
      "resolved": "https://registry.npmjs.org/@keystonehq/bc-ur-registry/-/bc-ur-registry-0.5.5.tgz",
        "@ngraveio/bc-ur": "^1.1.5",
    "node_modules/@keystonehq/bc-ur-registry-sol": {
      "resolved": "https://registry.npmjs.org/@keystonehq/bc-ur-registry-sol/-/bc-ur-registry-sol-0.3.1.tgz",
        "@keystonehq/bc-ur-registry": "^0.5.0",
        "@ngraveio/bc-ur": "^1.0.0",
        "@keystonehq/bc-ur-registry": "^0.5.0",
        "@keystonehq/bc-ur-registry-sol": "^0.3.1",
    "node_modules/@ngraveio/bc-ur": {
      "resolved": "https://registry.npmjs.org/@ngraveio/bc-ur/-/bc-ur-1.1.9.tgz",

Also npm install @ngraveio/bc-ur works in a new project

There were new versions of bc-ur published 16 and 11 hours ago, and the version before that was 3 years ago. So the issue could be coming from that new version.

Is anyone able to provide repro steps for this so I can take a closer look?

ChetanXpro commented 7 months ago

@mcintyre94 can you please try to use these library like this, and try to build your Nextjs project,These library are not creating any problem while installing.

"use client";

import React from "react";
import Header from "../Header";

import {
  ConnectionProvider,
  WalletProvider,
} from "@solana/wallet-adapter-react";
import { useMemo } from "react";
import {
  CloverWalletAdapter,
  PhantomWalletAdapter,
  SolflareWalletAdapter,
  MathWalletAdapter,
} from "@solana/wallet-adapter-wallets";
import { clusterApiUrl } from "@solana/web3.js";

const Sites = ({ children }: any) => {
  const wallets = useMemo(() => [new PhantomWalletAdapter()], []);

  const endpoint = useMemo(() => clusterApiUrl("mainnet-beta"), []);

  return (
    <ConnectionProvider endpoint={endpoint}>
      <WalletProvider wallets={wallets} autoConnect>
        <div className="">
          <Header />
          {children}
        </div>
      </WalletProvider>
    </ConnectionProvider>
  );
};

export default Sites;
mcintyre94 commented 7 months ago

Thanks @ChetanXpro, I've got a repro on stackblitz now: https://stackblitz.com/edit/nextjs-pksjhy?file=app%2Flayout.tsx

ChetanXpro commented 7 months ago

Thanks @ChetanXpro, I've got a repro on stackblitz now: https://stackblitz.com/edit/nextjs-pksjhy?file=app%2Flayout.tsx

Perfect , i think this issue might help you. raised recently, they also had this build issue. https://github.com/ngraveio/bc-ur/issues/21

mcintyre94 commented 7 months ago

Hmm that seems to have been before 1.1.9 was merged and we're still seeing the issue

ChetanXpro commented 7 months ago

Hmm that seems to have been before 1.1.9 was merged and we're still seeing the issue

For now i have used "@solana/wallet-adapter-backpack" to get BackpackWalletAdapter, this one is working fine , but its deprecated , so in future i will use @solana/wallet-adapter-wallets

mcintyre94 commented 7 months ago

Okay so it looks like this is an issue with the latest version of @ngraveio/bc-ur: https://github.com/ngraveio/bc-ur/issues/21#issuecomment-1973717698

This affects the keystone wallet adapter, but wallet-adapter-wallets is the common way to access all wallet adapters, and that has a dependency on keystone wallet adapter, and hence has this issue.

As you said, you can install from a specific wallet adapter as a workaround. But actually @ChetanXpro for Backpack, you don't need an adapter at all. Backpack implements wallet standard and will be picked up by all apps without needing to be listed. That's why that package is deprecated.

Most wallets now implement wallet standard and don't need to be imported and listed in wallets, which will hopefully make this less annoying to work around for now.

ChetanXpro commented 7 months ago

Thank you @mcintyre94 for sharing the update, sure i will remove these adapters from my code.

mcintyre94 commented 7 months ago

I was hoping we could fix this for everyone, and I think it will be fixed for some package managers, but with that stackblitz repo (using plain npm) I needed to add an override to the app too to get it working.

So:

Hopefully bc-ur will publish a fixed version at some point and this problem will go away!

As a reminder - you might not need wallet-adapter-wallets any more! Many wallets implement wallet standard and you don't need their adapter. If you don't need any adapters then you can drop this dependency.

mcintyre94 commented 7 months ago

Closing this - the latest version (1.1.12) of bc-ur works correctly and we've added overrides to use that version. This should be fixed now :) Sorry for the hassle!