MacOS终端 - SyntaxError:意外的令牌':'编译时

发布于 2025-01-25 06:26:53 字数 1875 浏览 3 评论 0 原文

全新的东西。试图在非技术领域为我的学士学位论文部署NFT。

我一直在遵循本指南: 直到我应该部署NFT并编辑HardHat配置文件以编译所有内容的地步一直很好。

当我使用Rinkeby时,该指南一直在使用“ Ropsten”网络。那是问题吗?

这是我的HardHat配置文件:

require("dotenv").config();
require("@nomiclabs/hardhat-ethers");

module.exports = {
  solidity: "0.8.0",
  defaultNetwork: "rinkeby",
  networks: {
    hardhat: {},
    rinkeby: {
      url: process.env.https://eth-rinkeby.alchemyapi.io/v2/MYURLCODE,
      accounts: [`0x${process.env.MYPRIVATEKEY}`],
    },
  },
};

这是我的错误消息:

MYNAME@Ivans-MacBook-Pro ethereum % npx hardhat compile
An unexpected error occurred:

/Users/MYNAME/nft-project/ethereum/hardhat.config.js:10
      url: process.env.https://eth-rinkeby.alchemyapi.io/v2/MYURL,
                            ^
SyntaxError: Unexpected token ':'
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1033:15)
    at Module._compile (node:internal/modules/cjs/loader:1069:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at importCsjOrEsModule (/Users/MYNAME/nft-project/ethereum/node_modules/hardhat/src/internal/core/config/config-loading.ts:28:20)
    at loadConfigAndTasks (/Users/MYNAME/nft-project/ethereum/node_modules/hardhat/src/internal/core/config/config-loading.ts:80:18)

非常感谢任何帮助!

Completely new to this stuff. Trying to deploy an NFT for my bachelor's thesis in a non-technical field.

I've been following this guide:
https://www.freecodecamp.org/news/how-to-make-an-nft/
And it's been going pretty well up until the point where I'm supposed to deploy the NFT and edit the HardHat config file to compile everything.

The guide has been using the "ropsten" network while I'm using rinkeby. Is that the problem?

This is my HardHat config file:

require("dotenv").config();
require("@nomiclabs/hardhat-ethers");

module.exports = {
  solidity: "0.8.0",
  defaultNetwork: "rinkeby",
  networks: {
    hardhat: {},
    rinkeby: {
      url: process.env.https://eth-rinkeby.alchemyapi.io/v2/MYURLCODE,
      accounts: [`0x${process.env.MYPRIVATEKEY}`],
    },
  },
};

And this is my error message:

MYNAME@Ivans-MacBook-Pro ethereum % npx hardhat compile
An unexpected error occurred:

/Users/MYNAME/nft-project/ethereum/hardhat.config.js:10
      url: process.env.https://eth-rinkeby.alchemyapi.io/v2/MYURL,
                            ^
SyntaxError: Unexpected token ':'
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1033:15)
    at Module._compile (node:internal/modules/cjs/loader:1069:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at importCsjOrEsModule (/Users/MYNAME/nft-project/ethereum/node_modules/hardhat/src/internal/core/config/config-loading.ts:28:20)
    at loadConfigAndTasks (/Users/MYNAME/nft-project/ethereum/node_modules/hardhat/src/internal/core/config/config-loading.ts:80:18)

Would be incredibly grateful for any help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云醉月微眠 2025-02-01 06:26:53

通过查看片段,我猜这行 url:process.env.https://eth-rinkeby.alchemyapi.io/v2/myurlcode 应该成为:

url: `https://eth-rinkeby.alchemyapi.io/v2/${process.env.MYURLCODE}`

假设您的 myurlCode ENV变量包含正确的值。

by looking at the snippet i guess this line url: process.env.https://eth-rinkeby.alchemyapi.io/v2/MYURLCODE should become:

url: `https://eth-rinkeby.alchemyapi.io/v2/${process.env.MYURLCODE}`

assuming that your MYURLCODE env variable contains the correct value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文