首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编制烟雾测试

编制烟雾测试
EN

Ethereum用户
提问于 2021-03-19 22:25:01
回答 1查看 95关注 0票数 0

我正在测试我的ganache编译器,看看它是否有效,我遇到了最荒谬的错误集。

这是我的密码:

代码语言:javascript
复制
pragma solidity ^0.5.0;

contract Token {
  string public name = "My Name";
} 

这是控制台:

代码语言:javascript
复制
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

我觉得这与我打开的其他文件有关,而不是代码本身。你认为如何?

EN

回答 1

Ethereum用户

发布于 2021-03-21 18:33:06

根据您的评论,您的松露配置中似乎存在一些格式化问题。我做了三个可能有帮助的改变:

代码语言:javascript
复制
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
            }
        }
    }
};
票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/94916

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档