Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

"no such file or directory" Doesn't Show Errant File/Directory Path #32

Closed
machineghost opened this issue Dec 15, 2016 · 5 comments · Fixed by #40
Closed

"no such file or directory" Doesn't Show Errant File/Directory Path #32

machineghost opened this issue Dec 15, 2016 · 5 comments · Fixed by #40

Comments

@machineghost
Copy link

machineghost commented Dec 15, 2016

I just got the following error from memory-fs:

Error: no such file or directory
    at MemoryFileSystem.readFileSync (/myproject/node_modules/memory-fs/lib/MemoryFileSystem.js:108:10)
    at MemoryFileSystem.readFile (/myproject/node_modules/memory-fs/lib/MemoryFileSystem.js:298:21)
    at devRoute (/myproject/backend/webpack.js:36:29)
    at Layer.handle [as handle_request] (/myproject/node_modules/express/lib/router/layer.js:95:5)
    at next (/myproject/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/myproject/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/myproject/node_modules/express/lib/router/layer.js:95:5)
    at /myproject/node_modules/express/lib/router/index.js:277:22
    at Function.process_params (/myproject/node_modules/express/lib/router/index.js:330:12)
    at next (/myproject/node_modules/express/lib/router/index.js:271:10)
    at Layer.handle [as handle_request] (/myproject/node_modules/express/lib/router/layer.js:91:12)
    at trim_prefix (/myproject/node_modules/express/lib/router/index.js:312:13)
    at /myproject/node_modules/express/lib/router/index.js:280:7
    at Function.process_params (/myproject/node_modules/express/lib/router/index.js:330:12)
    at next (/myproject/node_modules/express/lib/router/index.js:271:10)
    at SendStream.error (/myproject/node_modules/serve-static/index.js:121:7)

As you can see, there's no mention of the path it was trying to use to find a file/directory. However, when I looked at the code it was clear that it intended to share that path:

if(!isDir(current[path[i]])) 
    throw new MemoryFileSystemError(errors.code.ENOENT, _path); // Note the ",  _path"

and indeed, if I added a console .log ...

if(!isDir(current[path[i]])) console.log(_path)

it logged the path successfully. So evidently there's something wrong with MemoryFileSystemError which is causing it to ignore or discard it's second argument.

@machineghost machineghost changed the title "no such file or directory" Doesn't Show Errant File/Directory "no such file or directory" Doesn't Show Errant File/Directory Path Dec 15, 2016
@SpaceK33z
Copy link
Member

Thanks for your bug report. Would you be interested in filing a PR?

@machineghost
Copy link
Author

machineghost commented Dec 15, 2016

This seems like a quick fix for someone who is already knows the library, but I know nothing at all about it (I'm only using it as part of a co-workers setup). So while I'm happy to submit PRs in general, the odds of me learning your code well enough to submit one anytime soon are pretty slim. Sorry.

@sgnl
Copy link

sgnl commented Feb 3, 2017

Not sure what the best approach would have been but I submitted my PR and ready for review 🙇

mc-zone added a commit to mc-zone/memory-fs that referenced this issue May 30, 2017
1. Add path and operation name into error message, make it easier to figure out.

2. Change first line of stack to use correct message, instance of [object
Object].
mc-zone added a commit to mc-zone/memory-fs that referenced this issue May 30, 2017
1. Add path and operation name into error message, make it easier to figure out.

2. Change first line of stack to use correct message, instance of [object
Object].
@sokra sokra closed this as completed in #40 Jun 18, 2017
sokra added a commit that referenced this issue Jun 18, 2017
Prettify Error message and stack display, fix #32 .
@CyanChoi
Copy link

same error ... somebody help ...

@DimuthRuwantha
Copy link

same error ... somebody help ...

I had the same issue and after I removed yarn.lock file and install modules again fixed it

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants