【问题标题】:TypeError: Cannot read properties of undefined (reading 'path')TypeError:无法读取未定义的属性(读取“路径”)
【发布时间】:2021-11-05 23:34:51
【问题描述】:

我正在尝试使用此代码生成 NFT,但一直无法读取未定义读取路径的属性,如果有人知道修复方法,请回信。我对整个过程非常陌生,不知道我应该看什么,我一直按照我正在观看的 youtube 视频中所述的步骤进行操作,并且视频中的人没有发生此问题。

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

【问题讨论】:

    标签: node.js solana nft


    【解决方案1】:

    在命名图层文件夹中的图像时,您是否使用了除下划线字母 a 到 z 和主题标签以外的任何内容。如果是这样,这可能是您收到错误的原因。

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    【解决方案2】:

    我遇到了同样的问题。 原来layers文件夹是空的,我把图片保存在另一个路径,我以为是同一个。

    在图层文件夹中检查您是否保存了图像或路径是否符合您的想法。

    【讨论】:

      【解决方案3】:

      确保您的资产分层命名正确(仅使用下划线、a 到 z 和主题标签)。 也没有文件夹应该是空的

      祝你好运

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-22
      • 2021-12-29
      • 2018-02-26
      • 1970-01-01
      • 2021-12-31
      • 2015-05-25
      • 2021-11-24
      • 2021-11-26
      相关资源
      最近更新 更多