Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

110
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda