In my node.js project I have "@raydium-io/raydium-sdk": "^1.3.1-beta.52" dependency, and it has this deps:
`-- @project-serum/[email protected]
`-- @solana/[email protected]
`-- [email protected]
When I try to do import { Connection } from '@solana/web3.js'
and run the thing I get this error:
[INFO] 20:49:10 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.2, typescript ver. 5.4.5)
Error: Cannot find module 'rpc-websockets/dist/lib/client'
I dont understand whats the problem, probably something with module resolution, but I am not sure. I also checked and rpc-websockets are in the node_modules.
Any idea how to fix this?
3
Answers
Solved by explicitly stating "rpc-websockets": "7.11.0" in dependencies. It seems like latest version 7.11.0 is not compatible.
Just +1 as I’m having the same problem. Quick way to reproduce is creating a new NPM project (
npm init
), set"type": "module"
in package.json and runnpm i @solana/web3.js
.Trying to run any file (
index.js
) that just imports web3.js results in that errorI downgraded to "rpc-websockets": "7.10.0" which works for me.
Make sure to explicitly state this in package.json