Skip to content

Uncaught TypeError: Cannot read property 'NpmModule' of undefined #818

@Prinzhorn

Description

@Prinzhorn

I'm following the GridFS docs. The createObjectId and createBucket functions use MongoInternals. But MongoInternals is not available on the client. But the FilesCollection is created on both server and client. And hence createOnAfterUpload etc. are executed on the client.

Did this ever work? Or is the GridFS example broken? I'm new to Meteor and I find the mixing of Meteor.isServer and Meteor.isClient weird. Am I supposed to create a separate FilesCollection on the client but omit onAfterUpload etc?

I'm now doing this, which is ugli

const bucket = Meteor.isServer ? createBucket('attachments') : null;

export const Attachments = new FilesCollection({
  collectionName: 'attachments',
  allowClientCode: false,

  onAfterUpload: Meteor.isServer ? createOnAfterUpload(bucket) : undefined,
  interceptDownload: Meteor.isServer ? createInterceptDownload(bucket) : undefined,
  onAfterRemove: Meteor.isServer ? createOnAfterRemove(bucket) : undefined,
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions