const { Token, TOKEN_PROGRAM_ID } = require("@solana/spl-token");
const { Connection, PublicKey, Keypair } = require("@solana/web3.js");

async function main() {
// Your existing mint, payer, and recipient details
const mintPublicKey = new PublicKey("");
const recipientTokenAccount = new PublicKey("");
const payerKeypair = Keypair.generate(); // Your account that will pay for the transaction

// Establish a connection to the cluster
const connection = new Connection([link](https://rpc.ankr.com/solana_devnet/a62e9ca39b1ccedf47c1bd02af472a2438212b774438f46c4b8b10b3cb681d36), "confirmed");

// Create a new token instance
const token = new Token(
    payerKeypair // Use the payer's keypair for signing transactions

// Amount to mint (consider decimals)
const amountToMint = 150000000; // Adjust based on your token's decimals

// Minting new tokens to the recipient's token account
await token.mintTo(
    recipientTokenAccount, // Token account of the recipient
    payerKeypair.publicKey, // Payer of the transaction
    [], // Multisig owners (if applicable)
    amountToMint // Amount to mint

console.log(`Minted ${amountToMint} tokens to ${recipientTokenAccount.toString()}`);

main().catch(err => {
console.error("Error executing the script:", err);

After running pnpm install @solana/spl-tokens, I get still:

throw err;

Error: Cannot find module '@solana/spl-token'
Require stack:

at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object. (/mnt/c/Users/segura23/SeguraSafeSwap_Token/SeguraSafeSwap_Solana3/solana-program-library/services/js/blockchainConnection.js:1:37)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) {
requireStack: [
  • 1
    Could you share your package.json file. And check you installed @solana/spl-token not @solana/spl-tokens (extra s) as per your question
    – C.OG
    Nov 28, 2023 at 22:12

1 Answer 1


Did you install the spl-token package with pnpm install @solana/spl-token

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.