I read the solc document and followed the instruction.
When I am using [email protected] version, compile command is working fine

solc.compile(smartContractPath, 1);

When I switched to [email protected] version, compile command throwing error

(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath"normalize";var ret=nodeFS"readFileSync";i

AssertionError [ERR_ASSERTION]: Invalid callback specified.

In the solc documentation it is not mentioned about the changes in compile command.
Please tell how to use .compile function in [email protected] version.

  • Further down the documentation states: Starting from version 0.5.0, compile, compileStandard and compileStandardWrapper all do the same thing - what compileStandardWrapper used to do. There's some help how to use the new syntax here stackoverflow.com/a/49709550.
    – Ismael
    Nov 30, 2018 at 5:27
  • Yes, and below that it is also mentioned that compileStandard and compileStandardWrapper will be deprecated. Then only compile is remained there. In the error: it is giving error of invalid callback specified. May be in 0.5 callback is introduced in compile function but it is not mentioned in document Nov 30, 2018 at 5:41
  • compile in v0.5 expect a json string and output a json string. The format of the input is in solidity documentation. In the stackoverflow answer is the input equivalent to v0.4.xx behavior.
    – Ismael
    Nov 30, 2018 at 5:48

1 Answer 1


At first, I also tried your method to compile and got the same error.
Finaly, I found a workable method in the official doc.

I tried it with [email protected]. It's OK.

let contractSource = fs.readFileSync(contractPath, 'utf-8');
//console.log("contract content: \n" + contractSource);

let jsonContractSource = JSON.stringify({
    language: 'Solidity',
    sources: {
      'Task': {
          content: contractSource,
    settings: { 
        outputSelection: {
            '*': {
                '*': ['abi',"evm.bytecode"],   
             // here point out the output of the compiled result

let solcResult = solc.compile(jsonContractSource);  

You can see the output format of the compile in this link.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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