NativeScript / nativescript-cli

Command-line interface for building NativeScript apps
https://www.npmjs.com/package/nativescript
Apache License 2.0
1.04k stars 195 forks source link

console.log not working inside nativescript #3034

Closed davidsekielyk closed 6 years ago

davidsekielyk commented 7 years ago

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 commented 7 years ago

console.log("hello");

dtopuzov commented 7 years ago

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:

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 commented 7 years ago

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

davidsekielyk commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

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

etabakov commented 7 years ago

@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: https://github.com/NativeScript/nativescript-cli/issues/3141

smasala commented 6 years ago

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

des-esseintes commented 6 years ago

stuck with the same issue steps to reproduce:

des-esseintes commented 6 years ago

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

isawk commented 5 years ago

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 commented 5 years ago

@isawk,

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

isawk commented 5 years ago

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

GetCurious commented 5 years ago

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 commented 3 years ago

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

JimLynchCodes commented 3 years ago

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