Jim Lynch Codes
  • Blog
  • About Jim

Writings about one coder's stories & experiences.

Getting Started with Node.js: Hello World

12/28/2015

0 Comments

 
This is a basic tutorial for how to get started with Node.js and run node javascript files. 

Text Editor

There are really no fancy IDE's for Javascript. A nice Javacscript editor that I like is Sublime Text 2. 

Hello Command Line

If you want to use Node.js then you should get used to the command line. Node is meant to run on servers, and most servers are accessed through command line. But you don't need any special programs for that. You can use terminal on mac or run cmd on windows. You should get used to working in command line since you'll be using it a lot working with Node.js. you'll need to get the actual executable file called node that you can run in order to run a javascript file as a node file.
First, you'll have to download the node exectuable. 
Picture

Getting Started

If you downloaded it on mac, run the installer and follow the prompts. It will normally install to /usr/local/bin so let's go there. 
cd /usr/local/bin
I like to copy the node executable to a folder where I want to work with node js projects. This might be a good time to make a folder in your directory where you want to work with your own Node.js files. After that copy the node file over to your new folder using the cp command. Replace the second parameter with the path to the folder where you want "node" to be.  
cp node /Users/jimLynch/node-things
Then move into that new directory.
cd /Users/jimLynch/node-things
Ok, now we're ready to make a node.js file! Boot up sublime and let's get started! Plug this single line into your editor, and save it as Hello.js in the same folder where you copied the node executable. 
console.log("Hello Node World!")
Once you've saved that file, just go back to your command line application and run it. You can run javascript files by entering "node " and the same of the javascript file to run. The ".js" extension is optional. After you cd down to the directory with node and the file just created, enter this into the command line:
node Hello.js      // Hello Node World!
This should run the "Hello Node World" text that you entered in the the console.log() call from the javascript file. 

Where to Go From Here

This short tutorial showed you the basics for getting started with Node.js and running a javascript file on a server. Now you can take this power and put whatever you want inside the Hello.js file. Use multiple javascript files and external libraries to create something awesome! Good luck!
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    ​Author

    Picture
    The posts on this site are written and maintained by Jim Lynch. About Jim...
    Picture
    Follow @JimLynchCodes
    Follow @JimLynchCodes

    Categories

    All
    Actionscript 3
    Angular
    AngularJS
    Automated Testing
    AWS Lambda
    Behavior Driven Development
    Blockchain
    Blogging
    Business Building
    C#
    C / C++
    ClojureScript / Clojure
    Coding
    Community Service
    CS Philosophy
    Css / Scss
    Dev Ops
    Firebase
    Fitness
    Flash
    Front End
    Functional Programming
    Git
    Go Lang
    Haskell
    Illustrations
    Investing
    Java
    Javascript
    Lean
    Life
    Linux
    Logic Pro
    Music
    Node.js
    Planning
    Productivity
    Professionalism
    Python
    React
    Redux / Ngrx
    Refactoring
    Reusable Components
    Rust
    Security
    Serverless
    Shell Scripting
    Swift
    Test Driven Development
    Things
    TypeScript
    Useful Sites
    Useful Tools
    Video
    Website Development
    WebStorm
    Writing

    Archives

    March 2023
    August 2021
    February 2021
    January 2021
    October 2020
    September 2020
    May 2020
    April 2020
    February 2020
    January 2020
    December 2019
    October 2019
    September 2019
    August 2019
    July 2019
    June 2019
    May 2019
    April 2019
    March 2019
    February 2019
    January 2019
    December 2018
    November 2018
    October 2018
    September 2018
    August 2018
    June 2018
    May 2018
    April 2018
    March 2018
    February 2018
    January 2018
    December 2017
    November 2017
    October 2017
    September 2017
    August 2017
    July 2017
    May 2017
    April 2017
    March 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015

    RSS Feed

  • Blog
  • About Jim
JimLynchCodes © 2023