Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!