WalletConnect / web3modal

A single Web3 provider solution for all Wallets
https://web3modal.com
Apache License 2.0
4.8k stars 1.35k forks source link

[bug] Could not resolve "rpc-websockets/dist/lib/client" in @web3modal/solana/react #2551

Open rtomas opened 1 month ago

rtomas commented 1 month ago

Link to minimal reproducible example

https://github.com/rtomas/solana-walletconnect-example

Summary

Trying to run a simple example using @web3modal/solana/react as you can see in my github project and having

 [ERROR] Could not resolve "rpc-websockets/dist/lib/client"

    node_modules/.pnpm/@solana+web3.js@1.91.7_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@solana/web3.js/lib/index.browser.esm.js:12:37:
      12 │ import RpcWebSocketCommonClient from 'rpc-websockets/dist/lib/client';
         ╵                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  The path "./dist/lib/client" is not exported by package "rpc-websockets":

    node_modules/.pnpm/node_modules/rpc-websockets/package.json:5:13:
      5 │   "exports": {
        ╵              ^

  You can mark the path "rpc-websockets/dist/lib/client" as external to exclude it from the bundle,
  which will remove this error and leave the unresolved path in the bundle.

✘ [ERROR] Could not resolve "rpc-websockets/dist/lib/client/websocket.browser"

    node_modules/.pnpm/@solana+web3.js@1.91.7_bufferutil@4.0.8_utf-8-validate@5.0.10/node_modules/@solana/web3.js/lib/index.browser.esm.js:13:22:
      13 │ import createRpc from 'rpc-websockets/dist/lib/client/websocket.browser';
         ╵                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  The path "./dist/lib/client/websocket.browser" is not exported by package "rpc-websockets":

    node_modules/.pnpm/node_modules/rpc-websockets/package.json:5:13:
      5 │   "exports": {
        ╵              ^

  You can mark the path "rpc-websockets/dist/lib/client/websocket.browser" as external to exclude it
  from the bundle, which will remove this error and leave the unresolved path in the bundle.

List of related npm package versions

    "@solana/wallet-adapter-wallets": "^0.19.32",
    "@solana/web3.js": "^1.95.0",
    "@web3modal/solana": "^5.0.6",
rtomas commented 1 month ago

solved when added this package version "rpc-websockets": "7.11.0" (not the last one)

phoenixVS commented 1 month ago

Looks like some packaging issue I uninstalled the "rpc-websockets": "7.11.0", then I removed node_modules -> did pnpm i again and issue hasn't reproduced