'TypeError: Cannot read properties of undefined (reading 'path')

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,
}; ```


Solution 1:[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.

Solution 2:[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

Solution 3:[3]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Roundup
Solution 2 Sayed Khushal
Solution 3 Shava Rodriguez