Meteor-files: Cannot read property 'FilesCollection' of undefined

Created on 26 Jul 2016  ·  25Comments  ·  Source: veliovgroup/Meteor-Files

Hi
problem with Meteor-Files
using with Nova inside packages

meteor 1.3.2_4 (need for nova)
Meteor-Files v1.6.7

i have error
Cannot read property 'FilesCollection' of undefined

import { FilesCollection } from 'meteor/ostrio:files';

var Images;

Images = new FilesCollection({
  debug: true,
  collectionName: 'Images',
  allowClientCode: false, // Disallow remove files from Client
  onBeforeUpload: function (file) {
    // Allow upload files under 10MB, and only in png/jpg/jpeg formats
    if (file.size <= 10485760 && /png|jpg|jpeg/i.test(file.extension)) {
      return true;
    } else {
      return 'Please upload image, with size equal or less than 10MB';
    }
  }
});

if (Meteor.isServer) {
  Images.denyClient();
  Meteor.publish('files.images.all', function () {
    return Images.find().cursor;
  });

 Meteor.publish('files.images.all', () => Images.find().cursor);

} else {

  Meteor.subscribe('files.images.all');
}


export default Images ;

i try change to
Images = new Meteor.Files({
but not worked

and not worked update to coffeescript@=1.1.4

Most helpful comment

I'll merge and publish new version of MF today, please hold on

All 25 comments

Hi @fortunto2 ,
The [email protected] is only compatible with [email protected]
Use [email protected] for older versions of Meteor

@dr-dimitru
Yes, I tried different versions ... so i put the package manually by copying the latest version from github
but, not change

No, no, no.

meteor remove ostrio:files && meteor add ostrio:files@=1.6.6

And do not forget to remove local version of package from app/packages directory

i update Nova to meteor 1.4
so i use ostrio:files 1.6.7

and got new error

W20160727-03:40:32.815(5)? (STDERR) ReferenceError: Mongo is not defined
W20160727-03:40:32.815(5)? (STDERR)     at new FilesCollection (packages/ostrio:files/files.js:683:29)
W20160727-03:40:32.815(5)? (STDERR)     at meteorInstall.node_modules.meteor.lifefilm:lf-films.lib.uploader.server.images.collection.js (packages/lifefilm:lf-films/lib/uploader/server/images.collection.js:5:10)
W20160727-03:40:32.815(5)? (STDERR)     at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
W20160727-03:40:32.816(5)? (STDERR)     at Module.require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
W20160727-03:40:32.816(5)? (STDERR)     at Module.Mp.import (/home/rustam/.meteor/packages/modules/.0.7.5.it18e1++os+web.browser+web.cordova/npm/node_modules/reify/lib/runtime.js:70:16)
W20160727-03:40:32.816(5)? (STDERR)     at meteorInstall.node_modules.meteor.lifefilm:lf-films.lib.modules.js (/home/rustam/lifefilm/novalf/.meteor/local/build/programs/server/packages/lifefilm_lf-films.js:58:212)
W20160727-03:40:32.817(5)? (STDERR)     at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
W20160727-03:40:32.817(5)? (STDERR)     at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
W20160727-03:40:32.817(5)? (STDERR)     at /home/rustam/lifefilm/novalf/.meteor/local/build/programs/server/packages/lifefilm_lf-films.js:2913:1
W20160727-03:40:32.817(5)? (STDERR)     at /home/rustam/lifefilm/novalf/.meteor/local/build/programs/server/packages/lifefilm_lf-films.js:2919:3

i solve, after put 'mongo' to https://github.com/VeliovGroup/Meteor-Files/blob/master/package.js

  api.use(['mongo','underscore', 'check', 'random', 'coffeescript@=1.1.4', 'ecmascript', 'ostrio:[email protected]'], ['client', 'server']);

Weird, never faced issue with missed mongo packages as it build into the core, and if you will remove it from .meteor/packages file meteor app won't even start.
Could you post content of your .meteor/packages file?

it's nova)

############ Nova Core ############

nova:core # do not remove!

############ Optional Packages ############

nova:settings
nova:users
nova:posts
nova:comments
nova:newsletter
nova:search
nova:notifications
#nova:getting-started
nova:categories
nova:voting
nova:forms
nova:embedly
nova:api
nova:rss
nova:kadira
nova:email

############ Customizable Packages ############

nova:base-components
# nova:base-styles
# nova:base-routes
nova:email-templates
nova:i18n-en-us

accounts-password
accounts-twitter
accounts-facebook
accounts-google

############ Debug Packages ############

nova:debug

############ Your Packages ############

lifefilm:lf-routes
lifefilm:lf-films
lifefilm:nova-i18n-ru-ru
lifefilm:videojs
lifefilm:react-flexbox-grid

############ Party Packages ############


mrt:accounts-vk
templating

ostrio:files
ostrio:templatehelpers

File looks good to me.
Could you provide a link to nova rep or website, can't find it via github nor Atmosphere

http://www.telescopeapp.org/
https://github.com/TelescopeJS/Telescope
Telescope (blaze) - new short name Nova (react version)

@fortunto2 sorry for silence on my end.
Is this issue still persists on your end?

sorry me to
I am not sure that disappeared, tonight check.

Nova structure code with packages, so ues this packages in nova's packages there is no global "mongo".

api.use(['mongo','underscore', 'check', 'random', 'coffeescript@=1.1.4', 'ecmascript', 'ostrio:[email protected]'], ['client', 'server']);

Maybe @fortunto2 's code is the normal way

If you will add mongo to the project will it work?

yes need add 'mongo' (important for nova)
but i have new another error
Uncaught SyntaxError: Unexpected token import
for this
import { FilesCollection } from 'meteor/ostrio:files';

still I deal with the upgrade version of NOVA under the meteor 1.4

Add ecamscript and/or modules package(s)

maybe because after meteor 1.3 use the es6 import ,so when
use " import FilesCollection" from other packages file there is no global “mongo”
maybe use use " import FilesCollection" from a project file that's ok.
But A package use B package, A package's namespace do not share with B.

In Nova add this :
meteor-base
ecmascript
modules
mongo
ostrio:files
it still not work

ReferenceError: Mongo is not defined
for now the only way is @fortunto2 ‘s method

put 'mongo' to https://github.com/VeliovGroup/Meteor-Files/blob/master/package.js

api.use(['mongo','underscore', 'check', 'random', 'coffeescript@=1.1.4', 'ecmascript', 'ostrio:[email protected]'], ['client', 'server']);

I'll merge and publish new version of MF today, please hold on

after merge with 1.4
it's
import {FilesCollection} from 'meteor/ostrio:files';
work and in console give

I20160729-16:46:31.301(5)? [FilesCollection.storagePath] Set to: assets/app/uploads/Images
I20160729-16:46:31.309(5)? Ignoring duplicate publish named 'files.images.all'

but i have problem with NOVA
After connecting this collection, it pours

Where this Ignoring duplicate publish named 'files.images.all' comes from?

I'll merge and publish new version of MF today, please hold on

Everyone, sorry for delay with publishing new version.. I'll try to done it today.

from Meteor-Files)
maybe, same name conflict?

Impossible it is not publishing anything

Please see latest package update, let me know if issue still persists

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msgfxeg picture msgfxeg  ·  3Comments

tuarrep picture tuarrep  ·  4Comments

stefanve picture stefanve  ·  4Comments

rlhk picture rlhk  ·  4Comments

sylido picture sylido  ·  3Comments