metaplex-foundation / js

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

"process is not defined" error when using uploadMetadata #496

Closed Karen-Avdalyan closed 1 year ago

Karen-Avdalyan commented 1 year ago

I am testing getting-started-react-cra5 project from js-examples repository and I wanted to use uploadMetadata method to upload NFT metadata before minting it. Now I am getting ReferenceError: process is not defined error in console. Nothing is changed in configuration files and in package.json, only added react-wallet-adapter and related libraries to the project. image

Karen-Avdalyan commented 1 year ago

I found how to fix this issue. You need to add process in webpack plugins by changing this code in config-overrides.js

// Polyfill Buffer.
  webpackConfig.plugins.push(
    new webpack.ProvidePlugin({ Buffer: ["buffer", "Buffer"], process: "process/browser" })
  );
Karen-Avdalyan commented 1 year ago

Will be good if you will make needed change in example as well

lorisleiva commented 1 year ago

Hi there, thanks for sharing your solution. This is a frontend build issue though and not one related to the Metaplex JS SDK so I will close it. Feel free to open a PR on the js-example repository to add any extra polyfill that may now be required in the latest version of CRA5.