Skip to content

console.log not working inside nativescript #3034

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
davidsekielyk opened this issue Aug 3, 2017 · 17 comments
Closed

console.log not working inside nativescript #3034

davidsekielyk opened this issue Aug 3, 2017 · 17 comments

Comments

@davidsekielyk
Copy link

Hi, I'm new using nativescript and I just want to try console.log () but it does not show me anything in the terminal.
I run the program using tns run android using a USB to my phone
Other functions if I run but if I want to show something on console not.
Show me only

Successfully transferred login.js.
Refreshing application ...
Successfully synced application org.nativescript.Groceries on device 3AMCL16128044910.

And it shows nothing more

This is my code at login.js
Exports.loaded = function () {
     Console.log ("hello");
};
And in login.xml
The Page UI is so Page loaded = "loaded"

@priyangamani
Copy link

priyangamani commented Aug 4, 2017

console.log("hello");

@dtopuzov
Copy link
Contributor

dtopuzov commented Aug 4, 2017

Hi @davidsekielyk

It looks fine with this files:

login.js:

exports.loaded = function () {
     console.log("hello");
};

login.xml

<Page xmlns="http://schemas.nativescript.org/tns.xsd" loaded="loaded">
</Page>

app.js

var application = require("application");
application.start({ moduleName: "login" });

I think two might be the problems:

  • Typo in your code
  • Problem with specific android device (we can't get device log)

Can you please test on Android emulator?
If it is fine on Android emulator, then please specify your mobile device details (software and hardware).

@davidsekielyk
Copy link
Author

@priyangamani I used lowercase in console.log and exports.loaded, sorry for wrong copy in question

@davidsekielyk
Copy link
Author

@dtopuzov I tried to replace my code for which you put me as an example but it does not work, in my case I have this files

login.xml

<Page loaded="loaded"> </Page>

login.js

exports.loaded = function() { console.log("hello"); };

###app.js
var applicationModule = require("application"); applicationModule.start({ moduleName: "views/login/login" });

It does not throw me any errors and the app runs well on my cell phone but in console it still does not show me anything

The android emulator I could not make it run because I did not recognize the device and when it proves with the cell phone then I went with that

@kveretennicov
Copy link

I saw something similar. I followed the official tutorial on Ubuntu 16 LTS, using Android emulator, in livesync mode. I did not get "Hello World" in the output of tns run android.

However, when I ran tns device log in the second terminal, then "Hello World" began to appear in the output of tns device log and in the output of tns run android. After that console.log kept working even if I stopped tns device log, restarted tns run android or restarted the emulator.

So running tns device log once for the device may be the workaround.

@Gamadril
Copy link

XCode 9.0, MacOS High Sierra, iOS simulator test of Hello World template app. console.log does not work.

@etabakov
Copy link
Contributor

@Gamadril This is a known issue and it will be fixed in the next minor version of {N}, which is coming very soon. You can track the progress in this issue: #3141

@smasala
Copy link

smasala commented Jan 12, 2018

For others: instead of using the tns run android command, use tns debug android.

@des-esseintes
Copy link

stuck with the same issue
steps to reproduce:

  • create new project (tns create whatever);
  • add console.log("something") to main-page.js
  • tns android run -- the "something" is here, ok
  • tns plugin update; tns update
  • tns android run -- nothing! "something" is gone

@des-esseintes
Copy link

after updating everything and doing clean build i could see the logs again, great

@isawk
Copy link

isawk commented Apr 8, 2019

Issue appears to still exist, when using console.debug

Version/Environment Details

nativescript has 5.3.1
tns-core-modules has 5.3.1
tns-android has 5.3.1
tns-ios has 5.3.1

Emulator
Name: NexusDevice
...
Target: Google APIs (Google Inc.)
Based on: Android 6.0 (Marshmallow) Tag/ABI: google_apis/x86

JS: Angular is running in the development mode. Call enableProdMode() to enable the production mode.
JS: console.debug is not a function
JS: ERROR Error: Uncaught (in promise): TypeError: console.debug is not a function
JS: TypeError: console.debug is not a function

@Fatme
Copy link
Contributor

Fatme commented Apr 8, 2019

@isawk,

NativeScript does not support console.debug function. The full list of supported functions from console module can be found here.

@isawk
Copy link

isawk commented Apr 9, 2019

@Fatme Awesome thanks, worked in iOS, so didn't think it would be a problem on Android. Noted though.

@GetCurious
Copy link

GetCurious commented Aug 9, 2019

hmmm... i got nothing on the Device Logs from my Oppo f11 pro.
doing tutorial on the web editor

{
  "@angular/animations": "8.0.3",
  "@angular/common": "8.0.3",
  "@angular/compiler": "8.0.3",
  "@angular/core": "8.0.3",
  "@angular/forms": "8.0.3",
  "@angular/http": "8.0.0-beta.10",
  "@angular/platform-browser": "8.0.3",
  "@angular/platform-browser-dynamic": "8.0.3",
  "@angular/router": "8.0.3",
  "@progress-nativechat/nativescript-nativechat": "2.0.4",
  "kinvey-nativescript-sdk": "4.2.1",
  "nativescript-accelerometer": "2.0.1",
  "nativescript-angular": "8.0.2",
  "nativescript-background-http": "3.4.0",
  "nativescript-camera": "4.5.0",
  "nativescript-geolocation": "5.1.0",
  "nativescript-image": "2.1.4",
  "nativescript-imagepicker": "6.2.0",
  "nativescript-intl": "3.0.0",
  "nativescript-iqkeyboardmanager": "1.5.1",
  "nativescript-social-share": "1.5.2",
  "nativescript-theme-core": "1.0.6",
  "nativescript-ui-autocomplete": "5.0.0",
  "nativescript-ui-calendar": "5.0.0",
  "nativescript-ui-chart": "5.0.0",
  "nativescript-ui-dataform": "5.0.0",
  "nativescript-ui-gauge": "5.0.0",
  "nativescript-ui-listview": "7.0.0",
  "nativescript-ui-sidedrawer": "7.0.0",
  "nativescript-vue": "2.3.0",
  "reflect-metadata": "0.1.13",
  "rxjs": "6.5.2",
  "rxjs-compat": "6.5.2",
  "tns-core-modules": "6.0.1",
  "zone.js": "0.9.1"
}```

@JimLynchCodes
Copy link

this is still happening for me- console.log statements don't show in terminal when running with ns run ios

@JimLynchCodes
Copy link

With the command ns debug ios --watch I can see the log statements 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

14 participants