After updating my project: ReferenceError: check is not defined


#1

I had a project worked well with meteor 1.1.0.3
I did new installation for meteor to update it to version 1.2
I created a new project, copied all files of my old project
Then I did meteor add for all of the packages I used in the old project
After that I did meteor

I got this problem:

I20150925-14:58:48.269(2)? Exception while invoking method 'addUser' ReferenceError: check is not defined
I20150925-14:58:48.269(2)?     at [object Object].Meteor.methods.addUser (server/models/users.js:4:3)
I20150925-14:58:48.269(2)?     at maybeAuditArgumentChecks (livedata_server.js:1692:12)
I20150925-14:58:48.269(2)?     at livedata_server.js:708:19
I20150925-14:58:48.269(2)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20150925-14:58:48.270(2)?     at livedata_server.js:706:40
I20150925-14:58:48.270(2)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20150925-14:58:48.270(2)?     at livedata_server.js:704:46
I20150925-14:58:48.270(2)?     at tryCallTwo (/home/ahmed/.meteor/packages/promise/.0.4.8.1euaa8x++os+web.browser+web.cordova/npm/node_modules/meteor-promise/node_modules/promise/domains/core.js:45:5)
I20150925-14:58:48.270(2)?     at doResolve (/home/ahmed/.meteor/packages/promise/.0.4.8.1euaa8x++os+web.browser+web.cordova/npm/node_modules/meteor-promise/node_modules/promise/domains/core.js:171:13)
I20150925-14:58:48.271(2)?     at new Promise (/home/ahmed/.meteor/packages/promise/.0.4.8.1euaa8x++os+web.browser+web.cordova/npm/node_modules/meteor-promise/node_modules/promise/domains/core.js:65:3)

addUser is a method allow admin to add users, and It has those checks:

Meteor.methods({
	addUser: function(userAttributes) {
		check(Meteor.userId(), String);
		check(userAttributes, {
			username: String,
			password: String
		});

		var currentUserId = Meteor.user()._id;
		var adminId = Meteor.users.findOne({username: 'admin'});

		if (currentUserId === adminId._id) {
			Accounts.createUser(userAttributes);
			return true;

		} else {
			console.log("Someone - not permitted - tryied to create user.");
			return false
		}
	}
})

Meteor.users.allow({
	insert: function(userId, doc) {
		var username = Meteor.user().username;
		return username === "admin"
	}
})

Some told me that he hadn’t get the ‘check’ issue.


Upgrade Meteor 1.2.0.1 and deprecated package
#2

try

meteor add check


#3

Really!! It worked.
Did meteor team divided meteor to smaller packages :smile:


#4

#6

meteor-platform is deprecated as of 1.2 (it still exists and would have solved your problem). The packages it pulls (pulled) in may be seen here: https://github.com/meteor/meteor/blob/devel/packages/meteor-platform/package.js


#7

Tho’ to be fair, the documentation has been suggesting for sometime (perhaps as far back 0.6 iirc) that project dependency packages should be explicitly declared even if they were in the core (meteor-platform) because at some stage they might be deprecated

now they have :wink:


#8

OMG thank you!!! Saved me serious hassle!


#9

Thank you friend. :grinning: