【发布时间】:2020-09-04 20:11:06
【问题描述】:
此 Node JS 代码来自 this project,我正在努力理解。
// initialize the next block to be 1
let nextBlock = 1
// check to see if there is a next block already defined
if (fs.existsSync(configPath)) {
// read file containing the next block to read
nextBlock = fs.readFileSync(configPath, "utf8")
} else {
// store the next block as 0
fs.writeFileSync(configPath, parseInt(nextBlock, 10))
}
我收到此错误消息:
Failed to evaluate transaction: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received type number (1)
我对 NodeJS 不太熟悉,谁能向我解释如何更改此代码以消除错误?
【问题讨论】:
标签: node.js