简体   繁体   English

fs 错误:EISDIR:对目录的非法操作,读取

[英]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.

相关问题 EISDIR - EISDIR:对目录的非法操作,读取 - EISDIR - EISDIR: illegal operation on a directory, read 节点:使用 fs.readFile 获取错误:EISDIR:对目录进行非法操作,读取 - Node: Using fs.readFile getting Error: EISDIR: illegal operation on a directory, read Discord.js 错误:EISDIR:对目录的非法操作,请阅读 - Discord.js Error: EISDIR: illegal operation on a directory, read webpack模块节点产生错误EISDIR:对目录的非法操作 - webpack module node produces error EISDIR: illegal operation on a directory Firebase 云功能:错误:EISDIR:对目录的非法操作 - Firebase cloud function: Error: EISDIR: illegal operation on a directory 使用npm脚本编译sass - node-sass返回EISDIR:对目录的非法操作 - Compiling sass with npm scripts - node-sass returns EISDIR: illegal operation on a directory 在目录上非法操作,打开 - illegal operation on a directory, open 使用fs.createReadStream()和EISDIR同时进行`open`和`error` - Both `open` and `error` at same time with fs.createReadStream() and EISDIR 使用 fs writeFile 时出现 EISDIR 错误,但该文件夹确实存在 - EISDIR error when using fs writeFile, but the folder does exist 运行“rails s”错误(Errno :: EISDIR)`read':是一个目录@ io_fread / public / dev_assets - Running “rails s” error (Errno::EISDIR) `read': Is a directory @ io_fread /public/dev_assets
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM