我正在测试我的ganache编译器,看看它是否有效,我遇到了最荒谬的错误集。
这是我的密码:
pragma solidity ^0.5.0;
contract Token {
string public name = "My Name";
} 这是控制台:
SyntaxError: Unexpected identifier
at wrapSafe (node:internal/modules/cjs/loader:1024:16)
at Module._compile (node:internal/modules/cjs/loader:1072:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Module.require (node:internal/modules/cjs/loader:997:19)
at Object.require (node:internal/modules/cjs/helpers:92:18)
at Function.load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:161:1)
at Function.detect (/usr/local/lib/node_modules/truffle/build/webpack:/packages/config/dist/index.js:150:1)
at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/compile.js:68:1)
at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:136:1)
at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/cli.js:57:1)
at __webpack_require__ (/usr/local/lib/node_modules/truffle/build/webpack:/webpack/bootstrap:19:1)
at /usr/local/lib/node_modules/truffle/build/webpack:/webpack/bootstrap:83:1
at Object.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:89:10)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
Truffle v5.1.63 (core: 5.1.63)
Node v15.5.0我觉得这与我打开的其他文件有关,而不是代码本身。你认为如何?
发布于 2021-03-21 18:33:06
根据您的评论,您的松露配置中似乎存在一些格式化问题。我做了三个可能有帮助的改变:
require('babel-register');
require('babel-polyfill');
require('dotenv').config(); // you are missing the dot `.` between `require('dotenv')` and `config()`
module.exports = {
networks: {
development:
{
host: "127.0.0.1",
port: 7545,
netowrk_id: "*"
},
},
contracts_directory: './src/contracts/', // there was a dot `.` at the end of this line, where it should be a comma
contracts_build_directory: './src/abis/',
// Configure your compilers
compilers: {
solc: {
version: "0.5.0", // you are missing your Solidity compiler version
optimizer: {
enabled: true,
runs: 200
}
}
}
};https://ethereum.stackexchange.com/questions/94916
复制相似问题