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

fs.readFileSync is not a function #165

Closed
Fayde opened this issue Jul 25, 2017 · 6 comments
Closed

fs.readFileSync is not a function #165

Fayde opened this issue Jul 25, 2017 · 6 comments
Labels

Comments

@Fayde
Copy link

Fayde commented Jul 25, 2017

Recently updating my angular dependencies to angular cli 1.1.1 and related packages to 4.2.2 and this is being thrown from mime.js, any ideas because i'm lost

@broofa
Copy link
Owner

broofa commented Jul 26, 2017

I assume this is browser-side code, where the fs module is just shimmed with an empty object (or whatever).

That error is probably coming from mime's legacy support for the mime#load() method, here. I left that method in when I switched from reading the Apache configuration file to, instead, use the mime-db dataset (as types.json). This code was never really intended to be run in the browser, but apparently some module somewhere is trying to call into it...?

Easy way to identify the culprit is to edit your node_modules/mime/mime.js file and throw a console.trace() statement in there and see what shows up.

@aarohmankad
Copy link

aarohmankad commented Aug 7, 2017

Can you think of any fix for this? I need to use the intimidate package for uploading a Buffer to S3, and it requires mime.

I'm also getting the error, and can't seem to find anywhere where mime#load() is called. I do see placed where mime#lookup() is called. Is lookup() vulnerable to the same issue?

@aarohmankad
Copy link

Okay so it seems mime itself is calling mime#load(). Is there any alternative method of writing the following piece of code that will allow mime to run in the browser?

image

@broofa
Copy link
Owner

broofa commented Aug 7, 2017

@aarohmankad try doing npm install mime@latest. intimidate depends on "mime@^1.2.9". Forcing npm to install the latest version (which doesn't call mime.load() during initialization) may fix this issue.

@aarohmankad
Copy link

aarohmankad commented Aug 7, 2017

@broofa It does fix the issue! I submitted a PR to intimidate to upgrade the mime version. Don't think it will be merged anytime soon though. (Last commit was 2015.)

@broofa broofa added the V2 label Sep 15, 2017
@broofa
Copy link
Owner

broofa commented Sep 15, 2017

load() removed in v2

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

No branches or pull requests

3 participants