Getting start with angularjs (installation)

angularHere are some key steps to make angularjs running on a CentOs 6. Angularsjs is a javascript framework from Google. This post is describing the first step to install nodejs, yeoman (bower, grunt) … up to the server start and kind of hello world display.

 

Installing some pre-req

libpng-devel is requiered when creating the angular project

# yum install libpng-devel

Installing nodejs

Node.Js is an asynchronous javascript opensource application server.

Get the last version of node.js binaries on http://nodejs.org/download/ ; then download it.

# cd /tmp
# wget http://nodejs.org/dist/v0.10.31/node-v0.10.31-linux-x64.tar.gz
# cd /usr/local
# tar --strip-components 1 -xzf /tmp/node-v*.tar.gz

Installing Ruby & compass

Grunt we will install later have a dependency on Compass which requiring ruby, we need to proceed installation first:

# yum install ruby ruby-gems
# gem install compass

Installing Yeoman

Yeoman is a set of 3 tools :

  • Yo is able to automate project creation
  • Bower is managing project dependency
  • Grunt is automating build task

To install these component, we are using npm command, part of node.js package

# npm install -g yo grunt-cli bower
# npm install -g generator-angular

Creating a project

Now we can create the first angular project. The generator will ask a couple of question, say Yes to all then select all the proposed module in the list.

# cd ~
# mkdir HelloWorld
# yo angular HelloWorld

Fire the node.js server

We are going to use grunt to start the webserver, to access the server from outside by modifying the Gruntfile.js file. Search the following part in the file and modify hostname to get the same result.

 // The actual grunt server settings
 connect: {
    options: {
       port: 9000,
       // Change this to '0.0.0.0' to access the server from outside.
       hostname: '0.0.0.0',
       livereload: 35729
    },

Now we are ready to fire the server

# grunt serve

And connecting to http://your.server.name:9000/ you should get

 

2014-08-23 20:43:05 +00001

 

This entry was posted in Programming and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.