RangeError: Maximum call stack size exceeded when try Compilation in Solidity
RangeError: Maximum call stack size exceeded when try Compilation in Solidity
当我尝试在控制台中执行时
node compile.js
我收到这个错误。
RangeError: Maximum call stack size exceeded when try Compilation in Solidity
Invox.sol:
pragma solidity ^0.4.25;
contract Invox {
string public message;
function Invox (string initialmessage) public {
message = initialmessage;
}
function setMessage(string _message) public {
message = _message;
}
}
compile.js:
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const invoxPath = path.resolve(__dirname, 'contracts', 'invox.sol');
const source = fs.readFileSync(invoxPath, 'utf8');
//We have replaced the following line, but the issue persists
module.compile = solc.compile(source, 1).contracts[':Invox'];
//console.log(solc.compile(source, 1));
package.json:
{
"name": "invox",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"solc": "^0.4.25"
}
}
可能你的nodejs版本太高.
我在使用节点v12.16.0
时遇到了这个问题。
但是,当我将它切换到 v8.5.0
时,一切正常。
npm 安装 --save solc@0.4.17
运行 上述命令并更改 invox.sol
中的 solidity 版本
pragma solidity ^0.4.25; -> 实用性 ^0.4.17;
当我尝试在控制台中执行时
node compile.js
我收到这个错误。
RangeError: Maximum call stack size exceeded when try Compilation in Solidity
Invox.sol:
pragma solidity ^0.4.25;
contract Invox {
string public message;
function Invox (string initialmessage) public {
message = initialmessage;
}
function setMessage(string _message) public {
message = _message;
}
}
compile.js:
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const invoxPath = path.resolve(__dirname, 'contracts', 'invox.sol');
const source = fs.readFileSync(invoxPath, 'utf8');
//We have replaced the following line, but the issue persists
module.compile = solc.compile(source, 1).contracts[':Invox'];
//console.log(solc.compile(source, 1));
package.json:
{
"name": "invox",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"solc": "^0.4.25"
}
}
可能你的nodejs版本太高.
我在使用节点v12.16.0
时遇到了这个问题。
但是,当我将它切换到 v8.5.0
时,一切正常。
npm 安装 --save solc@0.4.17
运行 上述命令并更改 invox.sol
中的 solidity 版本pragma solidity ^0.4.25; -> 实用性 ^0.4.17;