npm solc: AssertionError [ERR_ASSERTION]: Invalid callback specified
Which version of solc are you using?
Solc released a breaking version the other day, this error is related to that.
npm uninstall solc
npm install [email protected]
This is because of version mismatch of solidity compiler installed during solc package installation and the compiler mentioned in the solidity file.To solve this issue try
install:
npm install [email protected]
in solidity file use :
pragma solidity^0.4.25;
This is because the version mismatch of Solidity compiler. Please note or verify the solidity compiler version in which you want to work. For example: If you are doing work in
pragma solidity ^0.4.17
then you have to install 0.4.17 solidity compiler version like this:
npm install [email protected]
in the command prompt or terminal.
If you are using latest version ie. 0.5.9 there is change in how you compile the code.
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const helloPath = path.resolve(__dirname, 'contracts', 'hello.sol');
const source = fs.readFileSync(helloPath, 'UTF-8');
var input = {
language: 'Solidity',
sources: {
'hello.sol' : {
content: source
}
},
settings: {
outputSelection: {
'*': {
'*': [ '*' ]
}
}
}
};
console.log(JSON.parse(solc.compile(JSON.stringify(input))));