This is the first contract with this Udemy course.

Trying to compile by running: "node compile.js" but get the following error:

iii@iii:~/inbox$ node compile.js 

throw err; ^ 

AssertionError [ERR_ASSERTION]: Invalid callback object specified. 
at runWithCallbacks (/home/iii/Digital Ledger/inbox/node_modules/solc/wrapper.js:97:7) 
at compileStandard (/home/iii/Digital Ledger/inbox/node_modules/solc/wrapper.js:207:14) 
at Object.compileStandardWrapper [as compile] (/home/iii/Digital Ledger/inbox/node_modules/solc/wrapper.js:214:14) 
at Object.<anonymous> (/home/iii/Digital Ledger/inbox/compile.js:9:6) 
at Module._compile (internal/modules/cjs/loader.js:689:30) 
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10) 
at Module.load (internal/modules/cjs/loader.js:599:32) 
at tryModuleLoad (internal/modules/cjs/loader.js:538:12) 
at Function.Module._load (internal/modules/cjs/loader.js:530:3) 
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)

This is my "compile.js" code:

const path = require('path');
const fs = require('fs');
const solc = require('solc');

const inboxPath = path.resolve(__dirname, 'contracts', 'inbox.sol');
const source = fs.readFileSync(inboxPath, 'utf8');

module.exports = solc.compile(source, 1);

And the simple contract:

pragma solidity ^0.4.17;

contract Inbox {
    string public message;

    function Inbox(string iniMess) public {
        message = iniMess;

    function setMess(string newMess) public {
        message = newMess;

And this is the file structure:


Thank you for any help :)

  • 1
    You should ask for a refund. The version used in the example solc 0.4.17 was released 3 years ago. Every serious development is with solc 0.5, and new project started to use 0.6. – Ismael Apr 29 '20 at 19:26
  • which other course would you suggest? – h1c0 Jul 24 '20 at 4:15
  • I know this is an old thread, but this doesn't do anything when I run node compile.js in terminal. Is it meant to do that? – Hana Ali Jan 18 at 20:22

That course is outdated, solidity version 0.6.6 is released and you better update your code to that version. if you are not a good programmer you better refund that course, cause you will encounter many problems later on, you will see some errors using meta mask and Web3. that course teachs you a lot, so i really recommend you to keep learning that course and update yourself throughout the course. this is the first problem and the solution to the updated version is this.

this will be your "inbox.sol" code:

pragma solidity ^0.6.6;

contract Inbox{
    string public message;

    constructor (string memory initialMessage) public{
        message = initialMessage;

    function setMessage(string memory newMessage) public{
        message = newMessage;

and this will be your "compile.js" code:

const path = require('path');
const fs = require('fs');
const solc = require('solc');

const inboxpath = path.resolve(__dirname, 'Contracts', 'Inbox.sol');
const source = fs.readFileSync(inboxpath, 'UTF-8');

var input = {
    language: 'Solidity',
    sources: {
        'Inbox.sol' : {
            content: source
    settings: {
        outputSelection: {
            '*': {
                '*': [ '*' ]

var output = JSON.parse(solc.compile(JSON.stringify(input)));

exports.abi = output.contracts['Inbox.sol']['Inbox'].abi;
exports.bytecode = output.contracts['Inbox.sol']['Inbox'].evm.bytecode.object;

in the new solidity the compiler will give you another version of compiled code compared to old compiler, so you'll need to pass the json file to your compiler and in order to access to abi(interface) and bytecode you need to do like i did in here.


@Anurag's answer is correct. You just need to check your versions and please be advised that the version of some libraries in that course are outdated. One big example is 'web3'. The instructor will tell you to install a specific version but you must install the latest version using the command

npm install --save web3

Apart from this, the truffle-hdwallet-provider is also deprecated. So make sure to install the latest one, which I believe is @truffle/hdwallet-provider (the latest version will work perfectly with the course and you will just have to do some minor tweaking into the deploy script.

I have done that course and I can confidently say that it is an amazing course. You will be lost into the wild world of blockchain if you didnt have such good reference material.


I got into same issue. Check which solc version are you using. Or else follow these steps

npm uninstall solc
npm i --save solc@0.4.17
node delpoy.js

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.