Attempting to move a custom token from one account to another by following this detailed tutorial.
Facing an issue with four errors showing up for all imports from the @solana/spl-token
package.
Tried removing the node-modules folder and reinstalling npm as suggested in this post, but no luck. Same error persists.
The strange part:
Even after uninstalling the package, I still encounter the same error! How is it possible that the compiler thinks the package is still present? What is happening?
The root cause seems to be that the previous version of the package 0.1.8
did not have those imports, whereas the latest version 0.2.0
does. I have installed 0.2.0
. It's explicitly mentioned as ^0.2.0
in my package.json file
I am new to TypeScript so any guidance (including tips on better debugging) would be greatly appreciated :)
Update: (title changed to reflect progress)
Suspecting a dependency issue... noticed from package-lock.json
that there are numerous other packages installing @solana/spl-token
as a dependency, here's an example:
"@raydium-io/raydium-sdk": {
"version": "1.1.0-beta.0",
"resolved": "https://registry.npmjs.org/@raydium-io/raydium-sdk/-/raydium-sdk-1.1.0-beta.0.tgz",
"integrity": "sha512-yN5M9sZNHazdMiUof2pHCBHs8FoGrfi2AWbLKAtKgnpJAWoyG7aLMLjeaVBc2L/xPuGsttUPP46dtqODwquJlg==",
"requires": {
"@colors/colors": "^1.5.0",
"@solana/buffer-layout": "^3.0.0",
"@solana/spl-token": "^0.1.8",
"big.js": "^6.1.1",
"decimal.js-light": "^2.5.1",
"fecha": "^4.2.1",
"lodash": "^4.17.21",
"toformat": "^2.0.0"
},
"dependencies": {
"@solana/buffer-layout": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-3.0.0.tgz",
"integrity": "sha512-MVdgAKKL39tEs0l8je0hKaXLQFb7Rdfb0Xg2LjFZd8Lfdazkg6xiS98uAZrEKvaoF3i4M95ei9RydkGIDMeo3w==",
"requires": {
"buffer": "~6.0.3"
}
},
"@solana/spl-token": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.1.8.tgz",
"integrity": "sha512-LZmYCKcPQDtJgecvWOgT/cnoIQPWjdH+QVyzPcFvyDUiT0DiRjZaam4aqNUyvchLFhzgunv3d9xOoyE34ofdoQ==",
"requires": {
"@babel/runtime": "^7.10.5",
"@solana/web3.js": "^1.21.0",
"bn.js": "^5.1.0",
"buffer": "6.0.3",
"buffer-layout": "^1.2.0",
"dotenv": "10.0.0"
}
}
}
},
Seems like TypeScript somehow imports the dependency? To resolve this weirdness, I found a workaround:
import { getOrCreateAssociatedTokenAccount, transfer } from "../node_modules/@solana/spl-token"
This isn't a final solution, which is why I'm leaving this question open. Unsure why TypeScript is loading the subfolder instead of the main one.