On Dec 29, 2014, at 2:12 AM, noderiety wrote:

Hello, I just finished installing nodejs on ubuntu. I wanted to do a simple Hello World to get started so I executed the following at the command prompt:

node console.log('hello world')

However, this returns the following error:

-bash: syntax error near unexpected token '('

Any idea what might be causing this issue and how to fix?

Yes! You're actually mixing up two different things. The node command-line consists of a script to run, and arguments to pass to it, parsed by the shell -- the shell is what's giving you the error, because you're giving it javascript, not simple space-separated arguments like command-lines take. (you can do more, but quoting rules abound!)

So what you want to do is put your one-line script in a file -- call it 'hello.js' perhaps, then:

node hello.js

It should print out "hello world"


Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscribe@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/44ED1D21-5F1E-4E76-AFE4-9B8F3A6B4AE7%40nbtsc.org.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 5 | next ›
Discussion Overview
groupnodejs @
postedDec 29, '14 at 3:01p
activeDec 30, '14 at 3:08p



site design / logo © 2021 Grokbase