Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
cannot run javascript program in terminal Mac

I have made a JavaScript hello world program in BBEdit, and saved it as app.js. But when I'm trying to run the file in Terminal, I keep getting the error (syntax error near unexpected token `'Hello world'').

The code:

console.log("Hello world")

The odd thing is, when I type node and then console.log("Hello world") into terminal, it works, just not when placing app.js directly into terminal.

What am I doing wrong?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It seems that you are attempting to run the JavaScript as if it was a shell script (dragging app.js on to Terminal).

What you will have to do instead is run the JavaScript file with Node.

Open Terminal and then type:

node app.js

Make sure you have the correct path to find your JavaScript file and it should work as you expect.

Make sure your system knows where node is, of course.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda