【发布时间】:2026-02-23 20:10:02
【问题描述】:
我是 NodeJs 的新手,但我一直在关注 Udemy 的教程。下面给了他一个来自 open.fs 的缓冲区。它给了我 int 3。
错误:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received type number (3)
在错误所在的断点调试变量:
err: null
fd: 3
this: undefined
.
const {promises, open} = require('fs');
const {readFile} = promises
open('./EventEmitter.js', (err, fd) => {
if (err) {
console.log(err);
return;
}
readFile(fd, 'utf8')
.then(data => {
console.log(data);
})
.catch(err => console.log(err))
})
【问题讨论】:
标签: node.js