Skip to content

meteor: when importing on the client throws error #554

@epaminond

Description

@epaminond

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions