MacOS终端 - SyntaxError:意外的令牌':'编译时
全新的东西。试图在非技术领域为我的学士学位论文部署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)
非常感谢任何帮助!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过查看片段,我猜这行
url:process.env.https://eth-rinkeby.alchemyapi.io/v2/myurlcode
应该成为:假设您的
myurlCode
ENV变量包含正确的值。by looking at the snippet i guess this line
url: process.env.https://eth-rinkeby.alchemyapi.io/v2/MYURLCODE
should become:assuming that your
MYURLCODE
env variable contains the correct value.