So I was following an Ethereum development course but got stuck into this error while compiling my compile.js file. I have tried this solution also of ReInstalling solidity but it didn't work.
npm solc: AssertionError [ERR_ASSERTION]: Invalid callback specified
Below I have attached my compile.js code.
const path = require('path');
const fs = require('fs-extra');
const solc= require('solc');
const { url } = require('inspector');
const buildPath = path.resolve(__dirname, 'build');
fs.removeSync(buildPath);
const campaignPath= path.resolve(__dirname,'contracts', 'Campaign.sol');
const source=fs.readFileSync(campaignPath,'utf-8');
const output=solc.compile(source,1).contracts;
fs.ensureDirSync(buildPath);
for(let contract in output)
{
fs.outputJSONSync(
path.resolve(buildPath,contract + '.json'),
output[contract]
);
}
And here is the error I am getting.
assert.js:374
throw err;
^
AssertionError [ERR_ASSERTION]: Invalid callback object specified.
at runWithCallbacks (D:\react_work\kick_start\node_modules\solc\wrapper.js:97:7)
at compileStandard (D:\react_work\kick_start\node_modules\solc\wrapper.js:207:14)
at Object.compileStandardWrapper [as compile] (D:\react_work\kick_start\node_modules\solc\wrapper.js:214:14)
at Object.<anonymous> (D:\react_work\kick_start\ethereum\compile.js:12:19)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
at internal/main/run_main_module.js:17:11 {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}