metaplex-foundation / js

A JavaScript SDK for interacting with Metaplex's programs
356 stars 182 forks source link

ReferenceError: global is not defined #521

Open qertis opened 1 year ago

qertis commented 1 year ago

I try to connect metaplex for my application and get Reference error.

My code

import {  Metaplex } from '@metaplex-foundation/js'
import { Connection, clusterApiUrl, Keypair } from '@solana/web3.js'

const NETWORK = clusterApiUrl('devnet')
export const connection = new Connection(NETWORK)

console.log(Metaplex)

Libs in dependencies

"typescript": "~5.0.4",
"vite": 3.2.6,
"quasar": 2.12.0,
"@metaplex-foundation/js": "0.19.4",

Output: image

image

image

Vite warn message: https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility

grumpyoldman-io commented 8 months ago

This https://github.com/metaplex-foundation/js/issues/534#issuecomment-1781950976 solved it for me.