[英]fs Error: EISDIR: illegal operation on a directory, read
I'm getting "Error: EISDIR: illegal operation on a directory, read" after trying to read the content of a.json.在尝试读取 a.json 的内容后,我收到“错误:EISDIR:对目录的非法操作,已读取”。 This is how I'm trying to access the file.
这就是我尝试访问文件的方式。 I'm using the FileSystem of node js.
我正在使用节点 js 的文件系统。
fs.readFile( path, ( err, fileData) => {
if (err) {
throw err;
}
else {
return fileData;
}
});
While debugging I can see that the error is thrown before the if statement.在调试时,我可以看到在 if 语句之前抛出了错误。
Any idea?任何想法?
Maybe the path to the file is not the right one, make sure the path of your file looks like the one that appears in the following code:也许文件的路径不正确,请确保文件的路径与以下代码中出现的路径相似:
const fs = require('fs');
fs.readFile('PATH_TO_YOUR_FILE/File_Name.json', (err, fileData) => {
if (err) {
throw err;
} else {
console.log(JSON.parse(fileData));
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.