npm solc:AssertionError [ERR_ASSERTION]:指定了无效的回调 [英] npm solc: AssertionError [ERR_ASSERTION]: Invalid callback specified
本文介绍了npm solc:AssertionError [ERR_ASSERTION]:指定了无效的回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用npm solc编译Solidity智能合约.我尝试遵循不同的示例.链接到示例: https://medium.com/coinmonks/如何编译一个solidity-smart-contract-using-node-js-51ea7c6bf440
I am trying to compile solidity smart contract using npm solc. I tried to follow different examples. Link to example: https://medium.com/coinmonks/how-to-compile-a-solidity-smart-contract-using-node-js-51ea7c6bf440
我写了如下代码:
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const helloPath = path.resolve(__dirname, 'contracts', 'hello.sol');
console.log("First" + helloPath);
const source = fs.readFileSync(helloPath, 'UTF-8');
console.log("Second" + source);
console.log(solc.compile(source, 1));
运行以上代码时出现以下错误.
I am getting following error when running the above code.
AssertionError [ERR_ASSERTION]: Invalid callback specified.
at wrapCallback (C:\Users\mouazzamj058\solc_example\node_modules\solc\wrapper.js:16:5)
at runWithReadCallback (C:\Users\mouazzamj058\solc_example\node_modules\solc\wrapper.js:37:42)
at compileStandard (C:\Users\mouazzamj058\solc_example\node_modules\solc\wrapper.js:78:14)
at Object.compileStandardWrapper (C:\Users\mouazzamj058\solc_example\node_modules\solc\wrapper.js:85:14)
at Object.<anonymous> (C:\Users\mouazzamj058\solc_example\example.js:4:19)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
请帮助.
推荐答案
您正在使用哪个版本的solc?
Which version of solc are you using?
Solc前几天发布了一个破坏版本,与此错误有关.
Solc released a breaking version the other day, this error is related to that.
npm uninstall solc
npm install solc@0.4.25
这篇关于npm solc:AssertionError [ERR_ASSERTION]:指定了无效的回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文