Meteor package: no such template - meteor

I'm writing an internal package in my Meteor app, and I cannot seem to get it to expose the packages templates to the rest of the app.
In my package.js file I have the following:
api.use(['templating', 'spacebars', 'ui'], 'client');
api.addFiles([
'client/templates/notifications/notifications.html',
'client/templates/notifications/notifications.js',
'notify.js',
'lib/collections/notifications.js'
], 'client');
and in notifications.html I have
<template name="notifications">
...
</template>
Back in the rest of the app, I have a layout.html template which simply uses the template like {{> notifications}}. But this causes the error:
Exception from Tracker recompute function: Error: No such template: notifications
at Blaze.View.lookup (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2809:15)
at null.<anonymous> (http://localhost:3000/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:71:23)
at http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1808:16
at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2043:12)
at viewAutorun (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1807:18)
at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?517c8fe8ed6408951a30941e64a5383a7174bcfa:296:36)
at new Tracker.Computation (http://localhost:3000/packages/tracker.js?517c8fe8ed6408951a30941e64a5383a7174bcfa:214:10)
at Object.Tracker.autorun (http://localhost:3000/packages/tracker.js?517c8fe8ed6408951a30941e64a5383a7174bcfa:487:11)
at Blaze.View.autorun (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1806:19)
at null.<anonymous> (http://localhost:3000/packages/spacebars.js?7f53771c84a2eafac2b561c9796dda0d8af8e7f5:70:10)
Any help would be appreciated.

Hard to tell without having a repo to reproduce, but here's an idea: rubaxa:sortable is a package I wrote that exposes a template successfully. Try to see what's different in yours.
BTW, you only need to api.use('templating'). No need for 'spacebars' and 'ui' just to expose a template. You may need additional functionality though.

As I can't comment yet, I write here the answer from #saimeunt :
Have you actually added the package to the app ? I know this is kinda
silly but even if the package lives under the application packages/
directory you still have to meteor add it.
Go in packages directory and run :
meteor add <YOUR_PACKAGE>
It solved the issue.
Thank you #saimeunt !

Related

Meteor: Cannot read property 'config' of undefined

I'm trying to implement the accounts-ui in a mobile angular-meteor app. I have all the dependencies installed, and I'm trying to setup the Accounts.ui.config with the following code:
import { Accounts } from 'meteor/accounts-base';
Accounts.ui.config({
passwordSignupFields: 'USERNAME_AND_EMAIL'
});
But when I try to run the app, I get the following error:
TypeError: Cannot read property 'config' of undefined
at meteorInstall.server.auth.js (server/auth.js:4:1)
at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)
at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1)
at server/publications.js:124:1
at /home/ubuntu/workspace/musiker/.meteor/local/build/programs/server/boot.js:297:10
at Array.forEach (native)
at Function._.each._.forEach (/home/ubuntu/.meteor/packages/meteor- tool/.1.4.0.hylsrj++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
at /home/ubuntu/workspace/musiker/.meteor/local/build/programs/server/boot.js:133:5
I thought maybe I need to import accounts-ui for the page, but the docs clearly show importing the account-base. I also tried importing the accouns-ui and I still got the same error.
Thank!
-Erick
Add accounts package before using this.
Use this command in the project root to add the package
meteor add accounts-ui accounts-password
This should make your code work.
You need to add the config on client side code :
import { Accounts } from 'meteor/accounts-base';
Accounts.ui.config({
passwordSignupFields: 'USERNAME_ONLY',
});
Have a look here for more details.
It looks like you are trying to execute Accounts.ui.config on the server but this function is only available on the client.
It is Accounts.config.
Accounts.config({
passwordSignupFields: 'USERNAME_AND_EMAIL'
});
I have the same error.
First I put the JS into lib/startup/accounts-config.js or lib/accounts-config.js ,it still has error.
But it becomes effective when I put the JS into imports/startup/accounts-config.js. I don't know the reason.

Meteor: Could not resolve the specified constraints for this project: Unknown package

What are the constraints that Meteor is trying to resolve when it loads the packages at startup? Is it all related to versioning or is it actually looking at the code that you load with ap.use() in packages.js?
I am getting this error when I try to start up my project. I have a super-simple package file that I created with the meter create --package command. I put all of my files that make up the package into the directory that it created and moved that directory to .meteor/packages. I'm just trying to create a local package for now. Here's the contents of package.js in that directory:
Package.describe({
name: 'ammap-meteor',
summary: 'mapping library packaged for meteor ',
version: '1.0.0',
});
Package.onUse(function(api) {
api.versionsFrom('METEOR#0.9.0');
api.addFiles('ammap.js');
api.addFiles('ammap_amcharts_extension.js');
});
Package.onTest(function(api) {
api.use('tinytest');
api.use('ammap-meteor');
api.addFiles('ammap-meteor-tests.js');
});
My ammap-meteor-tests.js file is blank for the moment but it exists. Would that make a difference? And I assume you just omit the git: property from Package.onUse() for a local package, is that right?
OK, I was able to get past that error with the publish command:
meteor publish --create
So I did not succeed in making a local package (still not clear on that) but at least I can get the package to load now.

Error when using iron:router with Meteor 0.9.3.1

I am experimenting with Meteor and iron:router. I git cloned the examples from https://github.com/EventedMind/iron-router.git. I then cd-ed into samples/basic, and ran meteor update and meteor. My meteor version is 0.9.3.1
When I navigated to the website an error is displayed in console and the page is empty. The error is as below:
Exception from Tracker recompute function: Error: Couldn't find a template named "/" or "". Are you sure you defined it?
at null._render (http://localhost:3000/packages/iron_dynamic-template.js?32038885cb1dad7957291ffebfffcb7f8cd57d20:239:17)
at doRender (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1853:25)
at http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1795:16
at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:2029:12)
at viewAutorun (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1794:18)
at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:288:36)
at new Tracker.Computation (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:206:10)
at Object.Tracker.autorun (http://localhost:3000/packages/tracker.js?192a05cc46b867dadbe8bf90dd961f6f8fd1574f:476:11)
at Blaze.View.autorun (http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1793:19)
at http://localhost:3000/packages/blaze.js?7b7ff7ee2ccdccd85a1ad0d8dc9d96193e29e8b0:1847:10 debug.js:41
Can someone kindly advise what I am doing incorrectly?
Thanks in advance.
The reason you have this issue is there is a discrepancy between the iron-router#1.0.0-pre-x (like a Beta for 1.0) and the currently in use 0.9.x version of iron router.
The old notation for defining a route for http://localhost:3000/route, for the template route would be as follows:
Router.route("route", { path : '/' });
However in the new version, which is currently on github on devel (which I presume the examples are based on is as follows):
Router.route("/", function() {
this.render("route");
});
The problem is using the notation on the bottom would lead to the error Couldn't find a template named "/" since the first param of the Route.route is now a path instead of a template.
The way to fix this is to either use the pre-release version of iron router (the version string can be found in the package.js file on github):
meteor remove iron:router
meteor add iron:router#1.0.0-pre3
Or to use the old notation by looking at an example bundled with a release on github instead of the devel branch like this one: https://github.com/EventedMind/iron-router/tree/v0.9.2-rc0

Updating to Meteor 0.9.1 woes (broke the app big time)

I’ve had some serious problems after updating meteor to 0.9.1.
Here are some example errors from the console.
Uncaught TypeError: undefined is not a function -- in dynamic_template.js
Uncaught TypeError: Cannot read property ‘prototype’ of undefined -- in helpers.js
Uncaught TypeError: undefined is not a function -- in router.js
Uncaught TypeError: Cannot read property ‘RouteController’ of undefined -- in iron-router-progress.js
Uncaught TypeError: Cannot read property ‘RouteController’ of undefined -- in global-imports.js
And dozens of: Uncaught ReferenceError: Template is not defined -- in client view js files, both the hard copies that I have created and the apparently ephemeral files that meteor apparently creates on the fly.
And fewer dozens of: Uncaught ReferenceError: Meteor is not defined -- in the same kind of files.
And one: Uncaught ReferenceError: Spacebars is not defined -- in login_buttons_dialogs.html
And about 10 sockjs errors on GET — net:ERR_CONNECTION_REFUSED
I can’t help thinking that either something very basic was not accomplished during the update procedure or there are some very basic and widespread changes that need to be made in my code in order for it to run 0.9.1.
I’m building a app that is an extension and morph of the microscope app. It's not rocket science at this point. It was working last night before the update. It was 0.9.0.1 before the update.
All help and insight is appreciated.
Thanks for the guidance. All seems to be well now. This is what I did:
I created a new meteor app, removed 2 default packages, then added:
bootstrap
iron:router
mrt:accounts-ui-bootstrap-dropdown
accounts-password
mrt:iron-router-progress
sacha:spin
Then I copied my files from the broken app to the new app and viola', everything worked.
I see that the directory structure and its naming conventions have changed, colons in place of dashes in a few spaces and the direcory or namespace prefixes such as mrt, iron, and sacha.
Here's an unexpected thing. I previously had a folder called packages in which there was a folder for each package containing all its files. Now that folder is empty, but everything is still working. I'm clearly under informed about a few things.
Again, thanks for the guidance. Even though this was a pain, I see that the resulting changes needed to happen.
Best, Alex
Many packages are breaking on Meteor#0.9.1, I suggest you create a new Meteor app like so:
$ meteor create --release 0.9.0 app
$ cd app
$ meteor remove insecure
$ meteor remove autopublish
and then add all the packages you need with meteor add packagename and copy over all the files from your app.
Stick with Meteor#0.9.0 until you know you can safely upgrade!

Why is using accounts.ui.config crashing my app?

Code (as suggested in the ui-config documentation
):
Accounts.ui.config({
passwordSignupFields: 'USERNAME_AND_OPTIONAL_EMAIL'
});
Error: TypeError: Cannot call method 'config' of undefined
I figured out that the file created in your project (yourprojectname.js) is the client script. My problem was that I created a new file called "client.js", although I didn't have to do that. Stupid me!
Hopefully this will be help for to someone else.
If you have a client folder for client files it will work to add it there. I just added it to a config.js file I added in my Client folder and it works fine.
client/config.js
Accounts.ui.config({
passwordSignupFields: 'USERNAME_AND_OPTIONAL_EMAIL'
});

Resources