check is not defined in meteor.js - meteor

I am new to meteor, I was trying to use file upload using
tomitrescak/meteor-uploads
I successfully uploaded some file, but when I tried to delete the uploaded file, I got error in my terminal Reference Error:check is not defined
I have checked the documentation and searched the web regarding this error but could not find any solution for this.
Note: I got similar error while studing http://meteortips.com/second-meteor-tutorial/iron-router-part-1/
OS: Ubuntu 14.04
meteor: 1.2.1

TL;DR
$ meteor add check
Longer version
In Meteor version prior to v1.2, a core package called meteor-platform used to export some symbols, including check.
Since v1.2, this is no longer the case and those symbols are no longer available via the platform, but using dedicated packages instead.
It is likely that one of the packages that you are using (or your app code itself) is using check (probably in one of its methods) without declaring it as a dependency.
Until the package maintainers update the dependency, you should be able to overcome the error by adding check as a top-level dependency:
$ meteor add check
If you identify which package is causing the issue, you can report it on GitHub, or fork the package yourself, add the missing dependencies and submit a pull-request.

Related

Hot swap of local Meteor package

I am using local Meteor package for my app (not posted on Atmosphere.js).
When I update this package elsewhere, I proceed with the following:
Update version of the package.
Delete old package from /packages/ directory of the live app.
See my program search for packages 3(?) times and then crash:
Your app is crashing. Here's the latest log:
Errors prevented startup:
While selecting package versions:
error: unknown package in top-level dependencies: vladimir3000:testpack
Your application has errors. Waiting for file change.
Copy new package with new version.
See my app picking up the changes and going live again:
vladimir3000:testpack upgraded from 0.0.2 to 0.0.3
=>Meteor server restarted
Is there a way to avoid step 3 and more elegantly instruct meteor to replace one package with another. Meteor update would not work as the package is not on atmosphere.js. Or hot swap is something from SOA world not from blood and fibers of Meteor javascript?
You can simply paste over the files for the package.
When you delete the old package, Meteor sees a file change and rebuilds the app. Since the package no longer exists in the packages directory, Meteor will try to pull it down from Atmosphere since it sees that there is a dependency on vladimir3000:testpack in .meteor/packages.
It will attempt to resolve this dependency a few times, with each build failing because the package you are referencing is unknown.
You can stop meteor and delete and replace the folder. Or you can copy and paste over the folder. The second method is preferable because Meteor will simply rebuild with all of the new files, rather than rebuilding and trying to resolve the dependency using Atmosphere.

Automatically update dependencies declared by local Meteor packages

It is rather tedious when trying to get dependencies of local Meteor packages up-to-date.
Currently, they are specified in package.js like and I have to check for latest version of each dependency used and update manually.
E.g.
api.use([
'alanning:roles#1.2.14',
'aldeed:simple-schema#1.5.3',
'aldeed:collection2#2.8.0',
'iron:router#1.0.12',
'useraccounts:iron-routing#1.12.4'
]);
Can meteor-tool do this or is there a better way to update packages' dependencies, especially useful when you have multiple local packages in a project.
There is no real value in bumping the dependency version in package.js, as I mentioned in my comment. It could lead to the counter effect and break version resolution.
The expectation is to mention the minimal compatible version (with the same major version number). When your local package is updated, its .versions file is updated as well, which may hint the build system which version of the dependency is the preferred one to use (the one that your package was built with).
The closest thing that I can give as an answer is this quote of David Greenspan* taken from the Meteor forums:
We have made some small improvements to meteor update over time, but
we don't have a way for a package to ask for one of its dependencies
to be upgraded more aggressively. meteor update with no arguments will
take patch updates to indirect dependencies, but not minor versions. I
recently improved the messages that meteor update prints, so in the
next release, it should tell you if an indirect dependency is not at
the latest version after it runs (rather than printing the very wrong
message "All packages are at their latest compatible versions").
If you bump the minor version of a package, I think the expectation at
the moment is that you will republish the packages that depend on it
if you want their users to get the new version (after running the
tests to make sure all is well).
So, when the author of a package you depend on releases a new:
patch version: no need for you to do anything. The new version should be used automatically.
minor version: check that everything works and release a new patch version, as to acknowledge the new version.
major version: things are expected to break. Make the required changes and release according to semver rules.
I would not count on things behaving as they do right now, as the packaging system undergoes pretty significant rework in order to be more compatible with NPM (including the ability to directly require NPM packages from Meteor apps and packages), expected to be included in v1.3.
* (actually, Sacha Greif posted the quote).
This is from the docs:
In general, you must specify a package's version (e.g.,
'accounts#1.0.0' to use version 1.0.0 or a higher compatible version
(ex: 1.0.1, 1.5.0, etc.) of the accounts package). If you are sourcing
core packages from a Meteor release with versionsFrom, you may leave
off version names for core packages. You may also specify constraints,
such as my:forms#=1.0.0 (this package demands my:forms at 1.0.0
exactly), or my:forms#1.0.0 || =2.0.1 (my:forms at 1.x.y, or exactly
2.0.1).
So the answer is, it will not update your package.js script but it will download the latest compatible versions, depend on your settings.

How to re-use an already installed package in Meteor?

I installed couple of packages for 'Project A' (e.g bootstrap) assuming that it will be available for all subsequent projects. But when a new meteor project 'Project B' was created, meteor list showed only default packages. So my assumption that meteor packages are like ruby gems available globally is incorrect. As I work offline every now and then, Is there a way I can manually copy/re-use installed packages?
Yes they are similar to gems. Packages are installed in ~/.meteor/packages, in precompiled form. They can be installed globally this way.
When you add a package to your project it will essentially copy the package from there into your build-cache directory hidden in the .meteor directory of your project.
To install a package locally where you can easily re-use it you would have to clone the github repository of the package and place the output in the /packages directory of your Meteor app.
For example for bootstrap, twbs:bootstrap you would clone this reposistory: https://github.com/twbs/bootstrap, into a directory like /packages/twbs:bootstrap (name doesn't matter if its defined in the package.js file on the repository.
In general you can easily re-use a package without the hassle of adding it in manually like so. It's better to use the global packages which are kept up to date.
The trouble comes with being offline. If you use a local package its nearly guaranteed to always work. Whereas the global ones can give a bit of trouble once in a while when you try to add a package in as meteor tries to check the package is up to date, especially where npm packages are involved with the package.
To keep it short if you added a package in using meteor add twbs:bootstrap you should most likely be able to add it to another project using the same command. Only if you keep your packages & meteor up to date.

Meteor 0.9.x Update

How do I find out what is holding my app up from updating? I keep getting the 'This project is at the latest release which is compatible with your current package constraints.' message.
Here is the output from the update command:
Refreshing package metadata. This may take a moment.
Figuring out the best package versions to use. This may take a moment.
Figuring out the best package versions to use. This may take a moment.
Figuring out the best package versions to use. This may take a moment.
This project is at the latest release which is compatible with your
current package constraints.
My packages.js looks like so:
# Meteor packages used by this project, one per line.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.
accounts-base
accounts-password
alanning:roles#=1.2.9
arunoda:npm#0.2.6
ch-activity
ch-activityreport
ch-arrestreport
ch-assetreport
ch-citation
ch-fieldinterviewreport
ch-incidentreport
ch-inspectionreport
ch-location
ch-media
ch-narrative
ch-organization
ch-person
ch-property
ch-signature
ch-vehicle
cmather:iron-router#0.8.2
coffeescript
copleykj:mesosphere#0.1.9
d3
dash-patrol
email
less
mizzao:bootboxjs#4.2.1-master.1
mrt:accounts-ui-bootstrap-3#=0.3.3
mrt:leaflet#0.3.8
mrt:mongo-counter#1.1.0
notices
sacha:spin#2.0.4
standard-app-packages
tsega:bootstrap3-datetimepicker#=0.2.0
I have migrated all the ch-* and dash-* packages to the new format. Those are local, in app, packages. Those cannot be in public repositories.
Try replacing
cmather:iron-router#0.8.2
with
iron:router#0.9.1
in your packages file.
I'm think it may be because not all your packages are compatible with Meteor 0.9.0
If you want to check what packages are currently compatible enter this code:
meteor search (Package Name)
By default meteor will only return compatible packages, so you can find which packages aren't working by searching each one. If you can't find the package, then its probably not compatible and you aren't going to be able to run the latest version of Meteor unless you remove it.
Don't worry though! While Meteor 0.9.0 is quite buggy, they are working hard to update all the packages and patch the bugs. Just give it a few weeks to sort itself out if that doesn't work :)
Best Of Luck! Hope This Helped!
Meteor search is included in the latest release. Docs: http://docs.meteor.com/#meteorsearch
Try running this command and you should be able to access meteor search
meteor update
Also, the update should tell you if there's a package update available, although I had to run update (packagename) on each starred package for it to update
meteor update aldeed:collection2
I found that I had to remove my ~/.npm directory and run meteor again to resolve some npm dependencies I had. Perhaps you have some npm dependencies as well?

Error while installing natural node in meteor project

I am working on a meteor project. Have to use natural package for natural language facility. I installed that using 'npm install natural'. But when ran the project, got error as 'ReferenceError: require is not defined'.
Added this line: var abc=Meteor.require('natural'); in the file in which have to use it. But when I am running the project, it is showing error as:=> Started proxy.
=> Meteor 0.8.1.3 is available. Update this project with 'meteor update'.
=> Started MongoDB.
=> Errors prevented startup:
While building package `router`:
error: no such package: 'page-js-ie-support'
error: no such package: 'HTML5-History-API'
-- When tried to install the above listed missing packages, showing error as:
smart.json changed.. installing from smart.json, I got the following error after successfully installing various packages like natural, iron-router, paginated-subscription, router, accounts-ui-bootstrap-dropdown, spin. But after that showing following error. Why so?
/usr/local/lib/node_modules/meteorite/lib/dependencies/package.js:106
throw('Could not locate package.js within path ' + self.source.packagePa
^
Could not locate package.js within path /home/priya/.meteorite/packages/natural/NaturalNode/natural/d541ca394659521498ed36a7f6e03fef93163e53
-- The packages in my project are: I don't understand here as router package is already listed then why showing error while running the project.??
meteor list --using
standard-app-packages
bootstrap
router
accounts-ui-bootstrap-dropdown
accounts-password
spin
paginated-subscription
email
insecure
iron-router
npm
Please guide me in this direction. This error is becoming a recursive kind of error. Have broke my head in this problem but still stuck. Thanks in advance
You have a package called Natural (not sure which) which isn't built to the correct packages specifications or has been modified somehow.
This can't be fixed that easily, you would have to contact the author of the package to fix it or modify it yourself. I can't find NaturalNode on atmosphere so its likely a custom package.
You might want to make the rest of your app work to debug fixing it though. To do that you need to remove this package
Remove the files and folders in ~/.meteorite/packages
Look through your packages smart.json and remove the offending package (natural). and run mrt update. And remove the rest of the code in your app relating to natural that might stop your app booting up.
From what it looks like you've cloned https://github.com/NaturalNode/natural into meteorite somehow. You would have to look at how to build a package for meteor.
The files you have used are an npm module and don't just work with meteor if you copy the files in. You have to make a compatible meteorite package for it to work. Or use meteor-npm to use the npm module in your app directly.
This project may also help you get started as an example of how to make a wrapper for an npm module to use with meteor

Resources