1

I am following the Solana docs: "Example: Create a mint with metadata" using Javascript.

Why does an error say that "TokenMetadata" is not an export"?

It also said that this kind of action is only allowed in typescript, which I would rather not use. Is there an option for Javascript and why is it saying "not an export"? I used the entire exact code in the Solana docs and imported all required including from @solana/spl-token-metadata (referring to the code piece below):

 const metadata: TokenMetadata = {
    mint: mint.publicKey,
    name: 'TOKEN_NAME',
    symbol: 'SMBL',
    uri: 'URI',
    additionalMetadata: [['new-field', 'new-value']],
  };

1 Answer 1

1

You cannot use Typescript types in JS and that's why you are getting this error.

To make this work

  1. Remove the TokenMetadata import in your JS file

  2. In you package.json add the "type": "module", to support the use of import for ES modules.

  • The alternative if you want to use commonJS is to update all the "import" imports to require.

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.