Here is what I have deduced is the fastest way to get an app up and running with Node.js. This requires some familiarity with using the command line. I completed the Codeacademy course “Learn The Command Line” before beginning with Node.js. I think it helped me better understand what the commands are and what they do.
- Download and install Node.JS
- Open the node command prompt. (This was on a windows machine.)
- creates a folder for your app(s)
- changes command prompt directory to your app’s folder
- Creates json file for your app
- fill out applicable info or just hit enter until the file is created
npm install express
- installs express.js module in node.js
npm install express-generator -g
- installs express-generator module in node.js
- this module creates the web app’s structure once the command in the next step is entered
- ensures all app module dependencies are installed
- starts your server and web app
- Go to http://localhost:3000 in a browser. Port 3000 is the default port of Express.
- Your app is live.
- I learned most of this from this great blog post.
- The above does not include a database integration. I integrated with a MongoDB database by following the instructions in this post.
- This YouTube video was also very helpful to me for figuring out MongoDB and Node.js integration.
- An HTML shorthand language called jade (aka pug) comes stock within Express.js. Here’s further reading on the pros and cons.
- All of the above has been from my own studies. I do not claim anything listed as the most efficient or best way to use Node.js. This is what has worked for me over the past two days.
- It feels good to whip up a nimble app environment that is capable of producing and supporting world changing software; Node.js is used by Netflix, PayPal, Microsoft and Uber.