3

I'm attempting to generate NFTs using this code but keep getting cannot read properties of undefined reading path, if anyone knows of a fix please write back. I am very new to this whole process and do not know what i should be looking at, i've been following the steps exactly as stated in the youtube video i was watching and this problem was not happening with the person in the video.

const path = require("path");
const isLocal = typeof process.pkg === "undefined";
const basePath = isLocal ? process.cwd() : path.dirname(process.execPath);
const { MODE } = require(path.join(basePath, "constants/blend_mode.js"));
const { NETWORK } = require(path.join(basePath, "constants/network.js"));

const network = NETWORK.sol;

// General metadata for Ethereum
const namePrefix = "CHUMPSNFT";
const description = "2,222 Chumps storming Solana Beaches";
const baseUri = "ipfs://NewUriToReplace";

const solanaMetadata = {
  symbol: "CHUMP",
  seller_fee_basis_points: 700, // Define how much % you want from secondary market sales 1000 = 10%
  external_url: "https://www.loosebucks.net",
  creators: [
    {
      address: "HXzaa6foNqG3w7XaVykaH6jWAFpNkCfJeDyhXsih2U93",
      share: 100,
    },
  ],
};

// If you have selected Solana then the collection starts from 0 automatically
const layerConfigurations = [
  {
    growEditionSizeTo: 163,
    layersOrder: [
      { name: "Background" },
      { name: "Body Color" },
      { name: "Top" },
      { name: "Accessories" },
      { name: "Face" },
      { name: "Head" },
      { name: "Eyes" },
    ],
  },
  {
    growEditionSizeTo: 326,
    layersOrder: [
      { name: "Background" },
      { name: "Body Color" },
      { name: "Face" },
      { name: "Head" },
      { name: "Eyes" },
    ],
  },
  {
    growEditionSizeTo: 489,
    layersOrder: [
      { name: "Background" },
      { name: "Body Color" },
      { name: "Top" },
      { name: "Accessories" },
      { name: "Eyes" },
    ],
  },
  {
    growEditionSizeTo: 652,
    layersOrder: [
      { name: "Background" },
      { name: "Body Color" },
      { name: "Accessories" },
      { name: "Face" },
      { name: "Head" },
      { name: "Eyes" },
    ],
  },
  {
    growEditionSizeTo: 815,
    layersOrder: [
      { name: "Background" },
      { name: "Body Color" },
      { name: "Accessories" },
      { name: "Head" },
      { name: "Eyes" },
    ],
  },
  {
    growEditionSizeTo: 978,
    layersOrder: [
      { name: "Background1" },
      { name: "Body Color1" },
      { name: "Top1" },
      { name: "Accessories1" },
      { name: "Face1" },
      { name: "Head1" },
      { name: "Eyes1" },
    ],
  },
  {
    growEditionSizeTo: 1141,
    layersOrder: [
      { name: "Background" },
      { name: "Body Color" },
      { name: "Top" },
      { name: "Eyes" },
    ],
  },
  {
    growEditionSizeTo: 1304,
    layersOrder: [
      { name: "Background" },
      { name: "Body Color" },
      { name: "Accessories" },
      { name: "Face" },
      { name: "Eyes" },
    ],
  },
  {
    growEditionSizeTo: 1467,
    layersOrder: [
      { name: "Background" },
      { name: "Body Color" },
      { name: "Eyes" },
    ],
  },
  {
    growEditionSizeTo: 1630,
    layersOrder: [
      { name: "Background" },
      { name: "Body Color" },
      { name: "Face" },
      { name: "Eyes" },
    ],
  },
  {
    growEditionSizeTo: 1793,
    layersOrder: [
      { name: "Background" },
      { name: "Body Color" },
      { name: "Top" },
      { name: "Head" },
      { name: "Eyes" },
    ],
  },
  {
    growEditionSizeTo: 1956,
    layersOrder: [
      { name: "Background" },
      { name: "Body Color" },
      { name: "Accessories" },
      { name: "Eyes" },
    ],
  },
  {
    growEditionSizeTo: 2119,
    layersOrder: [
      { name: "Background1" },
      { name: "Body Color1" },
      { name: "Accessories1" },
      { name: "Eyes1" },
    ],
  },
  {
    growEditionSizeTo: 2282,
    layersOrder: [
      { name: "Background1" },
      { name: "Body Color1" },
      { name: "Top1" },
      { name: "Accessories1" },
      { name: "Face1" },
      { name: "Eyes1" },
    ],
  },
];

const shuffleLayerConfigurations = false;

const debugLogs = false;

const format = {
  width: 512,
  height: 512,
};

const text = {
  only: false,
  color: "#ffffff",
  size: 20,
  xGap: 40,
  yGap: 40,
  align: "left",
  baseline: "top",
  weight: "regular",
  family: "Courier",
  spacer: " => ",
};

const pixelFormat = {
  ratio: 2 / 128,
};

const background = {
  generate: true,
  brightness: "80%",
  static: false,
  default: "#000000",
};

const extraMetadata = {};

const rarityDelimiter = "#";

const uniqueDnaTorrance = 10000;

const preview = {
  thumbPerRow: 5,
  thumbWidth: 50,
  imageRatio: format.width / format.height,
  imageName: "preview.png",
};

module.exports = {
  format,
  baseUri,
  description,
  background,
  uniqueDnaTorrance,
  layerConfigurations,
  rarityDelimiter,
  preview,
  shuffleLayerConfigurations,
  debugLogs,
  extraMetadata,
  pixelFormat,
  text,
  namePrefix,
  network,
  solanaMetadata,
}; ```
Progman
  • 16,827
  • 6
  • 33
  • 48

3 Answers3

2

Make sure the naming of your assets in layers is correct(only use underscores, a to z and hashtag). Also no folder should be empty

Best of luck

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31038455) – pitamer Feb 15 '22 at 09:25
1

Are you using anything other than Underscores letters a to z and hashtags in the naming of your images in the layers folders. If so it's probably the reason why your getting an error.

Roundup
  • 11
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 07 '21 at 14:25
0

I had the same problem. It turned out that a layers folder was empty, I was saving the images in another path and I thought it was the same one.

In the layers folders check if you have images saved or if the path is what you think.