An alternative solution: echo "console.log('hello world')" | node
On Monday, December 29, 2014 5:11:01 PM UTC+2, Aria Stewart wrote: > > > > On Dec 29, 2014, at 2:12 AM, noderiety <andrew.d....@gmail.com > <javascript:>> 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" > > Aria -- 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+unsubscr...@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/795fdba7-c46d-42bf-a48b-07d6eddf140f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.