0 votes
1 view
in Blockchain by (12.8k points)

I am getting the following error on compiling the code with:-

code = fs.readFileSync('Voting.sol').toString()

solc = require('solc')

compiledCode = solc.compile(code)

It throws out this error:-

'{"errors":[{"component":"general","formattedMessage":"* Line 1, Column 1\\n  Syntax error: value, object or array expected.\\n* Line 1, Column 2\\n  Extra non-whitespace after JSON value.\\n","message":"* Line 1, Column 1\\n  Syntax error: value, object or array expected.\\n* Line 1, Column 2\\n  Extra non-whitespace after JSON value.\\n","severity":"error","type":"JSONError"}]}'

1 Answer

0 votes
by (29.8k points)

Hi there could be various reasons behind this, you should consider checking the following

  • npm version conflicts. Make sure that you have the right version of solc.
  •  File.sol was raw solidity smart contract, but you need to put Compiler Standard Input JSON into solc.compile()
  • You have to specify what type of encoding is used for the solidity file.

        code = fs.readFileSync('Voting.sol', 'utf8');

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...