Node.js RangeError: Maximum call stack size exceeded I dont get where my program get stuck in the loop?
Node.js RangeError: Maximum call stack size exceeded I dont get where my program get stuck in the loop?
大家好,我正在学习我的 udemy 课程,当我使用 windows 终端机使用我的编译器编译 node.js solidity 文件时遇到问题...这是我的错误得到:
compiler error message
并且要清楚显示我的 solidity 代码和 JavaScript 所以你们有更好的看法,如果你能更多地解释我做错了什么,那就太好了......抱歉我可能不会给出很多信息,但我希望你们能理解我的问题。
solidity and JavaScript code
compile.js 文件:
const path = require('path');
// fs = file system module
const fs = require('fs');
const solc = require('solc');
// give a path to a compiler the file you want to compile:
// "__dirname" means it will start the path from the files folder root in this project root folder is "Inbox"
const inboxPath = path.resolve(__dirname, 'contracts', 'Inbox.sol');
const source = fs.readFileSync(inboxPath, 'utf8');
console.log(solc.compile(source, 1));
和solidity.sol文件
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.4.17;
contract Inbox{
string public message;
constructor(string initialMessage) public {
message = initialMessage;
}
function setMessage(string newMessage) public {
message = newMessage;
}
}
您需要将 JSON 编码的 options
对象传递给 compile()
函数 - 而不仅仅是源代码(这就是您当前代码所做的)。
您可以在 solc
包 readme 中找到代码示例。
大家好,我正在学习我的 udemy 课程,当我使用 windows 终端机使用我的编译器编译 node.js solidity 文件时遇到问题...这是我的错误得到:
compiler error message
并且要清楚显示我的 solidity 代码和 JavaScript 所以你们有更好的看法,如果你能更多地解释我做错了什么,那就太好了......抱歉我可能不会给出很多信息,但我希望你们能理解我的问题。
solidity and JavaScript code
compile.js 文件:
const path = require('path');
// fs = file system module
const fs = require('fs');
const solc = require('solc');
// give a path to a compiler the file you want to compile:
// "__dirname" means it will start the path from the files folder root in this project root folder is "Inbox"
const inboxPath = path.resolve(__dirname, 'contracts', 'Inbox.sol');
const source = fs.readFileSync(inboxPath, 'utf8');
console.log(solc.compile(source, 1));
和solidity.sol文件
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.4.17;
contract Inbox{
string public message;
constructor(string initialMessage) public {
message = initialMessage;
}
function setMessage(string newMessage) public {
message = newMessage;
}
}
您需要将 JSON 编码的 options
对象传递给 compile()
函数 - 而不仅仅是源代码(这就是您当前代码所做的)。
您可以在 solc
包 readme 中找到代码示例。