0

I was testing my ganache compiler to see if it is working and I came across the most ridiculous set of errors

This is my code:

pragma solidity ^0.5.0;

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

This is the console:

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

I feel like it has to do with other files I have open and not the code itself. What do you think?

4
  • 2
    The Solidity code compiles correctly, so the error might be related to something else. What command and parameters did you use to compile? – Sergi Juanati Mar 20 at 6:21
  • I used truffle compile – Kaleb Amarante Mar 21 at 10:31
  • This is how I configured truffle, – Kaleb Amarante Mar 21 at 10:31
  • require('babel-register'); require('babel-polyfill'); require('dotenv') config(); module.exports = { networks: { development : { host : "127.0.0.1", port: 7545, netowrk_id: "*" }, }, contracts_directory:'./src/contracts/'. contracts_build_directory: './src/abis/', // Configure your compilers compilers: { solc: { optimizer: { enabled: true, runs: 200 } } } }; As you you can see I used Javascript to connect my project to my Ethereum node, is there a problem there? – Kaleb Amarante Mar 21 at 10:33
0

Based on your comments, it looks that there are some formatting issues in your truffle config. I have done three changes that might help:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.