facebook / hermes

A JavaScript engine optimized for running React Native.
https://hermesengine.dev/
MIT License
9.85k stars 630 forks source link

Property 'console' doesn't exist #675

Closed gxanshu closed 2 years ago

gxanshu commented 2 years ago

Bug Description

Hermes version: 0.11.0 React Native version (if any): OS version (if any): zorin os 16 lite (based on ubuntu 20.04) Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): x86_64

Steps To Reproduce

  1. just build hermes from the repo
  2. test hermes command with some javascript code

code example: console.log("Hemes works!");

The Expected Behavior

Hermes Works

Screenshot

Screenshot_2022-02-16_05-45-18

neildhar commented 2 years ago

Hi @aianshume, console is not a built-in in JavaScript. Hermes does not provide a console.log function, it is provided by React Native or any other Hermes integrator.

If you'd like to run the Hermes executable directly, you should be able to use the print function to print things to the console.

gxanshu commented 2 years ago

Hi @aianshume, console is not a built-in in JavaScript. Hermes does not provide a console.log function, it is provided by React Native or any other Hermes integrator.

If you'd like to run the Hermes executable directly, you should be able to use the print function to print things to the console.

nice one thank you

melroy89 commented 6 months ago

That is funny, since JS/TS runtimes like Node.js or Bun do know about console.

I believe Herman should create a simple wrapper, so all console.* calls will become print()

tmikov commented 6 months ago

@melroy89 absolutely, runtimes should provide an implementation of console. However Hermes is not a runtime like NodeJS or a Bun, it is a JS engine like v8 or JSC.

It would be convenient to add an implementation of console to the hermes tool.