Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json file reading fails with 'utf8' #140

Closed
seniorpreacher opened this issue Jun 22, 2015 · 4 comments
Closed

Json file reading fails with 'utf8' #140

seniorpreacher opened this issue Jun 22, 2015 · 4 comments

Comments

@seniorpreacher
Copy link

When I call "fs.readJsonFileSync(path, 'utf8')", I get the following error:

TypeError: Cannot use 'in' operator to search for 'throws' in utf8
    at Object.readFileSync (/Users/.../node_modules/fs-extra/node_modules/jsonfile/index.js:25:33)
    ...

OS: OS X Yosemite 10.10.3
Fs-extra: "0.18.4"

@jprichardson
Copy link
Owner

If you remove the param utf8, do you get the same error?

@seniorpreacher
Copy link
Author

No, it works fine then (this is my workaround for now)
But I'm worried about it, when our project will support multiple languages, it might be a problem. (in the next couple of month)
And it might be a problem for others too.

@jprichardson
Copy link
Owner

Another workaround should be {encoding: 'utf8'}.

@jprichardson
Copy link
Owner

Ok, this has been fixed in [email protected]. Delete and reinstall fs-extra to get the latest jsonfile version. In your case, npm rm fs-extra && npm -i --save [email protected]. Note: If you upgrade to [email protected], the method readJsonFileSync does not exist anymore; you'll have to use readJsonSync which is the exact same.

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

No branches or pull requests

2 participants