Why is console.log() not printing anything?
Asked Answered
S

6

25

Just getting started with Meteor, on Windows. Following the initial instructions, the automatically generated "Hello World" app is running on localhost. The text and button are there, but clicking it doesn't output anything to the console. However, replacing console.log() with alert() does show the text ("You pressed the button") in the pop-up window.

Slovakia answered 15/1, 2013 at 20:35 Comment(4)
What browser are you using?Alcorn
Could you post the code you are working with? (It's a good idea to do when you ask a question related to some code you are working with)Twister
Are you putting console.log inside a Meteor.isServer block? If so, it will render in the terminal from which you ran meteor to start your project, not the browser console.Grazynagreabe
@Alcorn Chrome v24 @Knownasilya First time I ask a question on Stackoverflow :) Here you go: if (Meteor.isClient) { Template.hello.greeting = function () { return "Welcome to patio."; } Template.hello.events({ 'click input' : function () { // template data, if any, is available in 'this' if (typeof console !== 'undefined') alert("You pressed the button"); } }); } @Grazynagreabe I guess that's it. It's in a Meteor.isClient block.Slovakia
F
23

the console.log() output is printed in the browser. but it gets cleared immediately if you are submitting a form or handling an event as the page automatically gets refreshed.

if you want it to work, 1.Use chrome browser 2. check "Preserve log" check box on the console. then you can see the log

Freudian answered 27/11, 2014 at 12:36 Comment(0)
G
8

@dimfisch - I didn't see a console.log in your code snippet above. At any rate, I'm reiterating my comment as an answer:

Any console.log entries that are inside a Meteor.isServer block will by default NOT show up in the browser's console log. They'll show in the terminal from where you launched your app via the meteor command.

Grazynagreabe answered 16/1, 2013 at 1:11 Comment(1)
Yes, that's because I replaced console.log with alert in the code. And since it's in a Meteor.isClient block I'm not seeing it in the terminal window. Thanks.Slovakia
L
8

For anyone coming by here and currently losing your mind: for me I had searched using the Filter textbox at the top of the console. If you forget to clear that, you wont see any of your logs that don't match the filter :)

Lemberg answered 23/5, 2021 at 2:46 Comment(0)
S
1

Make sure you are looking at the right console. It might be your console is not logging the page you are testing. :) Happened to me.

Surge answered 18/3, 2017 at 22:5 Comment(0)
M
0

On the console, the left of any console.log() you write to the console, there are a sidebar with several tabs: eg. 5 messages, 2 user messages, 4 errors, 1 warning, No info, No verbose etc.

I find myself this morning not selecting the '5 user messages' item on the left panel. Instead, I have selected the 'No errors' item accidently. So I don't see any console.log() there. That can be one of the reasons.

Mend answered 16/9, 2021 at 3:34 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Safford
S
-2

In the console sidebar, open the "X Info" tab where "X" is the number of messages or something.

Seagoing answered 22/9, 2021 at 13:49 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Safford

© 2022 - 2024 — McMap. All rights reserved.