Closed ashu8912 closed 5 years ago
The ENOENT probably means some part of the path (one or more subdirectories) is missing. If you're sure that's not the case, then please post a standalone test case, i.e., something that's ready to run.
when i tried by giving a manual path it does work
but for the dynamic path its not working the dynamic path for me when i console it is /Users/ashughildiyal/Desktop/WebDevelopment/pirpleNode/app/.data/test/sample.json and thats the exact path no subdirectories missing but it does not works for this path
for the baseDir i used path.join(__dirname,"/../.data/")
.data is the directory name
I'm going to close this for lack of a standalone test case. I have no reason to believe there is actually a Node.js bug. Try nodejs/help if you want to pursue this further.
I had the same issue - same error when attempting to create a directory/file within .data; however, when I only attempted to create a file in .data, it worked fine.
I agree with @edgewood1 I think this wasn't the case with the older versions of nodeJS. Here's a way to replicate running fs.open('../folderThatExists/folderThatDoesNot/fileThatDoesNot.json', 'wx')
So if you try fs.open('../folderThatExists/fileThatDoesNot.json', 'wx')
it shall work.
I am having the same issue.. in the filename argument, if I don't use the ${dir} then it works fine... just wanted to know if this worked for any of you guys and if yes, then how?
I am assuming that using 'wx' should allow creation of directory if it doesn't exist too in the path for the filename provided..
Version: 10.15.0 Platform: Darwin Ashus-Air.lan 18.2.0 Darwin Kernel Version 18.2.0: Fri Oct 5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64 Subsystem: fs