Trying to transfer a custom token from one account to the other using this guide.
For some reason I'm getting four errors on all the imports from the @solana/spl-token
package.
I've tried deleting the node-modules folder and rerunning npm install like in this post, but that didn't work. Still the same error.
The curious part:
I tried uninstalling the package and I still got the same error! That doesn't make sense? How is the compiler thinking that the package is still installed? What is going on?
The reason why it freaks out is because the previous version of the package 0.1.8
doesn't have those imports, but latest version 0.2.0
does. I installed 0.2.0
. I explicitly have ^0.2.0
in my package.json
I'm new to TS so any help (even suggestions on how to debug better) here would be appreciated :)
Update: (title changed to reflect progress)
I think it's a dependency issue... from package-lock.json
I saw there's a lot of other packages that install @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"
}
}
}
},
So somehow typescript imports the dependency? So dumb but this fixes it:
import { getOrCreateAssociatedTokenAccount, transfer } from "../node_modules/@solana/spl-token"
It's not an answer, which is why i'm keeping this question up, I don't know why TypeScript would load the subfolder and not the main one.