Search code examples
angularnativescript

Nativescript application not showing console.log messages in terminal


I create a new nativescript application (ns create xxxx) and then run it to get it loaded into a simulator (ns run ios).

Once running, I add a console log anywhere (on init, or as an action from a button click etc.) and it will not output to the console.

I have found a thread on Stack that posed a similar question but it looks like they never got much feedback (and others reported the issue).

I have tried running in the VSCode terminal as well as the regular terminal (so it's not a VSCode thing). I am completely floored on what could be causing this.


Solution

  • This looks strange because console.logs usually work ok. Please check the following

    1. Be sure that you do not run your application in release mode or with --env.uglify flag because it may cause drop logging

    2. Disable hot module replacement option. Sometimes it cause issues.

    3. Be sure to use correct console operations. For example console.debug is not supported. You can find full list here

    4. Remove node_modules, platforms and hooks folders before next run. Just in case.

    5. Don't you have console object overridden by some other object?

    6. Try to change your console.log command with alert and check if it works.

    Please, come back after your check all the points from this checklist, also please add the report from your ns doctor command, and let's see if we can move on

    Update:

    Since you're using MacBook based on M1 processor it seems that your question is related to this issue:

    https://github.com/NativeScript/nativescript-cli/issues/5454

    Unfortunately, the only advice I can give you for now is to follow the thread for some solution or workarounds