• Skip to main content
  • Skip to primary sidebar

Founder at work

Master the skills to create and launch your next SaaS company

  • About Me
  • Reviews
  • Resources
  • Community
  • Contact
  • Lessons
  • Series
  • Search
  • Login

Example App in Node.js

May 27, 2016 by Rick Hernandez Leave a Comment

Sample Application

Now that you understand the core concepts of Node.js let’s now create a simple application and execute it with Node.js with the terminal.

[code lang=text]
touch app.js
echo "console.log('(7 + 5) / 2 is ?', (7+5)/2)" >> app.js
node app.js
[/code]

Results

[code lang=text]
(7 + 5) / 2 is ? 6
[/code]

Working with REPL

[code lang=bash]
node
[/code]

node opens the interactive shell (also called REPL) a perfect
place to test simple one liners in JavaScript, to get out of it simply press Ctrl + C twice.

[code lang=text]
node

console.log('(7 + 5) / 2 is ?', (7+5)/2);
[/code]

Prints to the console and evaluates the expression

Results

[code lang=text]
(7 + 5) / 2 is ? 6
[/code]

Give some of the following commands a try with node.

OPTIONS

[code lang=bash]
-v, –version print nodes version
-e, –eval script evaluate script
-p, –print print result of –eval
-i, –interactive always enter the REPL even if stdin does not appear to be a terminal
–no-deprecation silence deprecation warnings
–trace-deprecation show stack traces on deprecations
–throw-deprecation throw errors on deprecations
–v8-options print v8 command line options
–max-stack-size=val set max v8 stack size (bytes
–enable-ssl2 enable ssl2 in crypto and https modules
–enable-ssl3 enable ssl3 in crypto and https modules
[/code]

You can find the above material plus all of the V8 OPTIONS that are available on github or if you are on a *nix system just use the man pages.

[code lang=bash]
man node
[/code]

Rick Hernandez

I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Filed Under: JavaScript, JSecademy, Node Basics, Programming

Primary Sidebar

Learn How To Take Your Idea And Convert It Into An App From Scratch Even If You Have Never Written A Single Line Of Code.

  • How to Find Your Next Great App Idea
  • The Secret To Getting PAID To Build Your Own App
  • How To Create Your App (SaaS, Mobile, VR, AR, Game)
  • How To Monetize Your Apps
Learn More
4.82 Ratings

Copyright © 2025 · JSecademy Blog Theme on Genesis Framework · WordPress · Log in