文件存在但接收到ENOENT错误 [英] File Exists But Receiving ENOENT Error

查看:83
本文介绍了文件存在但接收到ENOENT错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是要点: https://gist.github.com/973e70bde8e6a530c489

我有两种情况.即使代码完全相同,一种方法仍然有效,而另一种方法却失败了.

I have two scenarios. One works and one fails even though the code is exactly the same.

  1. 在包装盒上已获取一个CSV文件并进行解析.完美的作品.没问题.
  2. 采用刚刚创建的CSV文件并尝试对其进行解析,然后我收到:
  1. Take a CSV file already on the box and parse it. Works perfectly. No issues.
  2. Take a CSV file that was just created and attempt to parse it and I receive:

ENOENT,没有这样的文件或目录'/Users/Home/dev/csv/TwFrI5vhdownload.csv

相同的CSV文件格式等等.没关系,因为创建的文件甚至都不会打开.即使文件确实存在,它也会失败并显示上述错误.如果我重新启动Node并尝试获取该文件,则它可以正常工作.如果我在新创建的文件上运行fs.stat,它将失败.

Same CSV file format and all that. Wouldn't matter anyway because the created file won't even open. It fails with the error above even though the file does exist. If I restart Node and attempt to grab that file, then it works perfectly. If I run fs.stat on the newly created file it fails.

我尝试了超时,外部回调等.但是对于动态创建的文件,它总是会失败.

I've tried timeouts, external callbacks, etc.. but with the dynamically created file it always fails.

我在这里想念什么?文件被锁定了,我不知道吗?

What am I missing here? Is the file locked and I don't know it?

谢谢!

系统:

OSX Lion 节点v0.6.7

OSX Lion Node v0.6.7

推荐答案

您确定在尝试解析文件时确实创建了该文件吗?

Are you sure the file is actually created when you try to parse it?

我查看了要点,我想您是从某个位置下载文件然后解析的.没有完整的代码,我只能猜测,但是我认为您已经开始下载,但是您还没有收到明确的指示,表明已经可以下载了.

I took a look on the gist and I guess you are downloading the file from somewhere and then parsing it. Without the whole code I can only guess, but I think that you started the download, but you haven't received a clear indication it is there and ready to be parsed.

这篇关于文件存在但接收到ENOENT错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆