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

fs.promises readdir, readFile, etc. fail with ENOENT #455

Closed
plasne opened this issue Jun 27, 2018 · 10 comments
Closed

fs.promises readdir, readFile, etc. fail with ENOENT #455

plasne opened this issue Jun 27, 2018 · 10 comments

Comments

@plasne
Copy link

plasne commented Jun 27, 2018

fs.promises is still "Experimental" so there may be some bug with that, but readdir, readFile, etc. don't seem to work with assets, they all fail with ENOENT.

Just an FYI in case it saves someone else some time.

@Ks89
Copy link

Ks89 commented Sep 10, 2018

I have the same problem about fs #521
I also posted a log, but I still don't know how to fix that

@Ks89
Copy link

Ks89 commented Sep 10, 2018

Fixed in #521 for readFileSync

@jonim8or
Copy link

This issue is still there in pkg 4.2.2 when making a build with node 12. In node 12 fspromises is no longer experimental, so I would expect it to work.
I made a small project to test the support:
`
const fs = require('fs');
const fsPromises = fs.promises;
const path = require('path');
const file = path.resolve(path.join(__dirname, 'testfile.json'));

console.log(exists sync: ${fs.existsSync(file)});

fs.readFile(file, (err, data) => {
if (err) {
console.error(Failed to read ${file} using fs.readFile: ${err});
} else {
console.info(read file ${file} successfully using fs.readFile);
}
});
fsPromises.readFile(file).then(() => {
console.info(read file ${file} successfully using fsPromises.readFile);
}).catch(err=> {
console.error(Failed to read ${file} using fsPromises.readFile: ${err});
}
);
Output:
exists sync: true
read file D:\snapshot\pkg fspromise bug\testfile.json successfully using fs.readFile
Failed to read D:\snapshot\pkg fspromise bug\testfile.json using fsPromises.readFile: Error: ENOENT: no such file or directory, open 'D:\snapshot\pkg fspromise bug\testfile.json'
`

pkg fspromise bug.zip

@onip
Copy link
Contributor

onip commented Feb 13, 2020

this is still not working in pkg@4.4.3

@igorklopov
Copy link
Contributor

Will work on this next.

@nikoskleidis
Copy link

nikoskleidis commented May 28, 2020

Yes nextjs is almost unusable with pkg after this commit
vercel/next.js@2e1044f
part of this PR
You cannot read static pages through pkg at all. Only server side rendered ones

@ryanrhee
Copy link

ryanrhee commented Oct 8, 2020

I'm still running into this. Is there any progress here?

leafac added a commit to leafac/pkg that referenced this issue Feb 3, 2021
@leafac
Copy link

leafac commented Feb 3, 2021

I patched this on my fork at https://github.com/leafac/pkg

It’s available at npm install @leafac/pkg.

If the maintainers are interested in a pull request, I’d be happy to send it.

@leerob
Copy link
Member

leerob commented Mar 4, 2021

Merged!

@leerob leerob closed this as completed Mar 4, 2021
@leafac
Copy link

leafac commented Mar 4, 2021

Thanks @leerob! 🙌

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

No branches or pull requests

9 participants