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

meteor: when importing on the client throws error #554

Open
epaminond opened this issue Jul 21, 2016 · 1 comment
Open

meteor: when importing on the client throws error #554

epaminond opened this issue Jul 21, 2016 · 1 comment

Comments

@epaminond
Copy link

epaminond commented Jul 21, 2016

When using gm with meteor.js you may need to import gm in files that are used on both client and server. This way on the client you'll get an error: require(...).readFileSync is not a function even if you don't actually try to use gm.

This comes from this code in index.js:

module.exports.version = JSON.parse(
  require('fs').readFileSync(__dirname + '/package.json', 'utf8')
).version;

fs module on the client is an empty object which triggers an error. Can this be replaced with something like this?

module.exports.version = JSON.parse(
  require('fs').readFileSync
    && require('fs').readFileSync(__dirname + '/package.json', 'utf8')
    || "{}"
).version;
@epaminond
Copy link
Author

Created a pull-request, that fixes that: #556

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

1 participant