【发布时间】:2021-05-02 00:45:07
【问题描述】:
使用 fs.rmdir 函数时,我从 Ubuntu 收到此错误:
fs.js:136
throw new ERR_INVALID_CALLBACK();
^
TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
at makeCallback (fs.js:136:11)
at Object.rmdir (fs.js:671:14)
<...>
我不确定这是什么原因,因为当我在我的 Windows 10 计算机上进行本地测试时,它工作得非常好。
这是导致错误的代码:
// remove client's temporary directory and its files
fs.rmdir('temp/' + socketID, {recursive: true}, (error) => {
if(error) throw error;
});
另外,在 Ubuntu 机器上,如果我删除 {recursive: true} 选项,命令会运行并且回调可以工作,但它不能解决问题,因为我想要递归选项。
【问题讨论】: