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'
});
Related
I am working with Laravel Event Broadcasting and i am using pusher driver for broadcasting event and its working perfectly.
The public channel is subscribed successfully from client side using pusher provided js library
var pusher = new Pusher('xxxxxxxxxxxxxxxxxxxxx_my_app_key', {
encrypted: true
});
var channel = pusher.subscribe('TestPusher');
channel.bind('App\\Events\\TestPusher', function(data) {
alert(data.msg);
});
But when i use Echo in my client side code
Echo.channel('TestPusher')
.listen('TestPusher', (e) => {
console.log(e.msg, e.chatMessage);
});
It generates the error " Echo is not defined ".
I already installed the Laravel Echo library using npm install --save laravel-echo pusher-js in my application and also included the following code in resources/assets/js/bootstrap.js file as per the laravel provide documentation.
import Echo from "laravel-echo"
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'xxxxxxxxxxxxxxxxxxxxx_my_app_key'
});
So please help me how can i fix this problem.
My issue was that I was not compiling bootstrap.js together with the rest of the code because I had removed the line require('./bootstrap') from app.js. I added that line back and I was home and dry.
As described here
I had this problem a few days ago. My gulp installation was all messed up and Laravel versioning didn't help.
Sorry if this doesn't help, it's just my experience and most detailed as possible:
First, I'll consider you do have the js/app.js script included on you site.
Now, you're seeing this error because, as Josh mentioned, you're not compiling your js files. After editing 'resources/assets/js/bootstrap.js', this file needs to be compiled by running the asset compiler: gulp (named Laravel Elixir docs/5.3/elixir) in Laravel 5.3).
If you followed carefully this part of the tutorials, you shall be extra careful with laravel's npm dependencies versions, specially those used by Elixir (Once again, my gulp installation wasn't working at all even though no error messages showed up).
So, if this is a new project, you should consider updating to Laravel 5.4. If you can't or not willing to update all Laravel framework, perhaps this can be solved like I did. Staying at 5.3 but using the latest assets compiler on 5.4, named Laravel Mix. Now it runs on npm: npm run dev. (No gulp mentioned on doc.)
To achieve this, you should update to latest package.json on 5.4 and follow the 5.4 documentation to install Laravel Mix.
Your codes looks fine, Problem is your JS order so only you getting undefined issues
like
<script>
Echo.channel('TestPusher')
.listen('TestPusher', (e) => {
console.log(e.msg, e.chatMessage);
});
</script>
<script src="echo.js"></script>
so zigzag the order :)
widow object before each Echo.
window.Echo.channel('TestPusher')
.listen('TestPusher', (e) => {
console.log(e.msg, e.chatMessage);
});
remove defer from your app.js script tag
<!-- Scripts -->
<script src="{{ asset('js/app.js') }}" defer></script>
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.
i followed the Meteor Upload guide exactly , but i get this error when i load my uploading template.
any clues ?
Exception from Tracker recompute function: Cannot read property 'autoStart' of null
TypeError: Cannot read property 'autoStart' of null
at Template.upload.created (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/tomi_upload-jquery.js?b6bf3c0cc365d2eb8f9acc93ee3dcc4bfd892687:2569:29)
at null.<anonymous> (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2995:20)
at fireCallbacks (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1835:16)
at Object.Tracker.nonreactive (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/tracker.js?517c8fe8ed6408951a30941e64a5383a7174bcfa:513:12)
at http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1832:13
at Object.Blaze._withCurrentView (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2043:12)
at Object.Blaze._fireCallbacks (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1831:9)
at Object.Blaze._createView (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1849:9)
at Object.Blaze._materializeView (http://genjurosama-199720.euw1-2.nitrousbox.com/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:1853:9)
I've just tested it with Meteor for Windows and it works perfect for me.
Meteor.startup(function () {
UploadServer.init({
tmpDir: process.env.PWD + '/.uploads/tmp',
uploadDir: process.env.PWD + '/.uploads/',
checkCreateDirectories: true
})
});
Check what you are getting at process.env.PWD, I think issues comes from your enviroment. You need write permissions to that path. Also check out latest updates with meteor update.
Btw, it can be issue with nitrous enviroment.
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 !
i created an angular application with yeoman, when i executed grunt command i got the following error
Running "karma:unit" (karma) task
WARN [config]: JASMINE is not supported anymore.
Please use `frameworks = ["jasmine"];` instead.
WARN [config]: JASMINE_ADAPTER is not supported anymore.
Please use `frameworks = ["jasmine"];` instead.
WARN [config]: LOG_INFO is not supported anymore.
Please use `karma.LOG_INFO` instead.
ERROR [config]: Config file must export a function!
module.exports = function(config) {
config.set({
// your config
});
};
how do i solve this error ?
It's just those two predefined terms (JASMINE and JASMINE_ADAPTER)
that should not be used any more. All you have to do is open the
config file ./config/karma.conf.js and comment out those terms and add
frameworks = ["jasmine"];.
Via Yasuhiro Yoshida
apart from #sheplu's answer, there are additional changes that need to be done in karma.conf.js, you can see it in https://gist.github.com/sivakumar-kailasam/6421378
this gist solves your problem of 'Config file must be a export a function!'
The official docs has these changes as well http://karma-runner.github.io/0.10/config/configuration-file.html