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.
Related
I am trying to login Facebook with Firebase. I have installed all the libraries required and completed the required configuration. Still, whenever I try to start my app it is giving me this error:
(node:11160) UnhandledPromiseRejectionWarning: TypeError: Cannot read
property 'manifest' of undefined
at removeOldOptions (C:\Users\Dell\Desktop\firebaseapp\plugins\cordova- universal-links-plugin\hooks\lib\android\manifestWriter.js:48:32)ished in 37.33 s
at Object.writePreferences
(C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-
plugin\hooks\lib\android\manifestWriter.js:27:19)
at activateUniversalLinksInAndroid
(C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:65:25)
at C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:45:11
at Array.forEach (<anonymous>)
at run (C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:41:17)
at module.exports (C:\Users\Dell\Desktop\firebaseapp\plugins\cordova-universal-links-plugin\hooks\afterPrepareHook.js:18:3)
at runScriptViaModuleLoader (C:\Users\Dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:188:18)
at runScript (C:\Users\Dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:164:16)
(node:11160) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Able to solve this with below changes :
Just go to the below file in Ionic
plugins/cordova-universal-links-plugin/hooks/lib/android/manifestWriter.js
I fixed issue by changing pathToManifest as below:
var pathToManifest = path.join(cordovaContext.opts.projectRoot, 'platforms', 'android', 'cordovaLib', 'AndroidManifest.xml');
to
var pathToManifest = path.join(
cordovaContext.opts.projectRoot,
'platforms',
'android',
'app',
'src',
'main',
'AndroidManifest.xml');
For anyone that's looking into this these days, the actual fix for this was published by someone which you can pull in as a cordova plugin https://github.com/nordnet/cordova-universal-links-plugin/issues/133#issuecomment-369260863
#okaufmann you can use the changed version of the plugin. since it's not merged in the nordnet repository, you must remove the plugin and install again using:
cordova plugin add https://github.com/walteram/cordova-universal-links-plugin
After doing...
cordova plugin rm cordova-universal-links-plugin
cordova plugin add https://github.com/walteram/cordova-universal-links-plugin
.. my project was able to build successfully.
You need to update the AndroidManifest path in the plugin, which seems to be outdated. Check out this:
https://github.com/nordnet/cordova-universal-links-plugin/issues/146
My app works perfectly fine without a router. I'm using the nathantreid:css-modules package, which allows modular css for your react components. Within my imports/ui/Navbar directory, I have Navbar.jsx, containing:
// Custom Dependencies
import s from './Navbar.scss';
import NavButton from './NavButton/NavButton';
When I have the app load the components in client/main.jsx with the following:
Meteor.startup(() => {
render(<App />, document.getElementById('render-target'));
});
It works, but it doesn't work when I add either react or flow router and create a route:
FlowRouter.route('/', {
action() {
mount(App);
}
});
It throws the following:
W20160520-10:09:25.659(-7)? (STDERR) Error: Cannot find module './Navbar.scss'
W20160520-10:09:25.659(-7)? (STDERR) at require (packages/modules-runtime/.npm/package/node_modules/install/install.js:78:1)
W20160520-10:09:25.659(-7)? (STDERR) at meteorInstall.imports.ui.Navbar.Navbar.jsx (imports/ui/Navbar/Navbar.jsx:7:1)
W20160520-10:09:25.659(-7)? (STDERR) at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:141:1)
Would appreciate any technical insight as to how I might be able to fix this issue.
Also I would like to note that I've tried relative and absolute pathing, but the fundamental issue is that it only looks for NPM packages the moment I add a router (or at least that's my interpretation of what's happening).
I figured out a solution!
My underlying assumption might be wrong, but I think it has to do with load order. I moved my routes from the standard lib/ folder into my imports/ folder where I also have my other react modules. I then just imported/required the routes in my client/main.jsx and it worked!
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 !
So I've done the todo and leaderboard tutorials and now am excited to begin routing - seems like iron router is the way to go so I install it to my project using
mrt add iron-router
Seems to install ok so I start meteor and navigate to localhost:3000 and my console lights up with:
Uncaught TypeError: undefined is not a function
helpers.js:141 Uncaught TypeError: Cannot read property 'prototype' of undefined
router.js:61 Uncaught TypeError: undefined is not a function
global-imports.js?784bc180a149e4c10dff977a7f114df67d9952c6:3 Uncaught TypeError: Cannot read property 'RouteController' of undefined
template.tutorialexample.js?e119ff8df948cfe8167f49eb28794995a594841c:2 Uncaught ReferenceError: Template is not defined
tutorialexample.js?a4ef596255404350be2cc45303caea02f934cd17:1 Uncaught ReferenceError: Meteor is not defined
Mind you this is a default app, haven't touched a thing.
So if someone could point me in the right direction that would be great. I did read somewhere that I should be using 0.8.2 version of iron router - and I then did change my smart.json file to contain:
{
"packages": {
"iron-router": "0.8.2"
}
}
and then did meteor update etc but still no luck. So any help anyone could provide would be great.
Meteor has changed quite a bit & the instructions/tutorial you've been following is a bit dated.
Previously mrt was part of the meteorite packaging system, from Meteor 0.9.0 it has been integrated directly into meteor.
So now you do:
meteor add iron:router
To add it to your project. Once you start your app up it should present a basic template on how to use it.
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'
});