Saturday, July 26, 2014

Install yo (yeoman) in Ubuntu 14.04

Yeoman is a really cool scaffolding tool that comes with lots of pre-built generators for a range of applications. I use it for initiating angularJS applications using yo's 'official' angularJS generator.

In Ubuntu 14.04 (actually starting from 13.10) versions 0.10.x of nodejs are present in the official repositories. So in order to install nodejs package manager just type:

sudo apt-get install npm nodejs-legacy

npm alone is not sufficient to install Yeoman, since the latter depends on 'node' legacy binary during installation, hence nodejs-legacy package is also required.

Install global npm packages as a regular user.

npm installs packages under a 'prefix' configuration variable, which defaults to /usr/lib in Ubuntu 14.04. In order to avoid using sudo for every npm-install command, you may configure 'prefix' variable to point into a user local directory.

sudo npm set prefix '$HOME/<user-space-local-npm-directory>' --global
i.e.
sudo npm set prefix '/home/andy/dev/npm' --global

Verify that setting has been set using; defaults to /usr/lib

sudo npm get prefix

Update your $PATH variable to include the location npm installs binaries,

echo "export PATH=$PATH:$HOME/dev/npm/bin" >> $HOME/.profile

and restart your terminal session.

Install Yeoman

Installing yeoman is dead simple; just invoke

npm install -g yo

as mentioned in the official site.

AngularJS scaffolding

Install angularJS generator

npm install -g generator-angular

Generate angularJS application

yo angular

Invoke grunt to build the application grunt serve (or python -m SimpleHTTPServer) to preview the application.

3 comments:

  1. Great that you have mentioned clearly about the subject which I have missed at online Angularjs training. Thanks for the clear cut presentation of the information.

    ReplyDelete
  2. Thanks for sharing this valuable information to our vision. You have posted
    a trust worthy blog keep sharing.
    Angularjs Training In Hyderabad

    ReplyDelete
  3. In order to get yo to install I had to do it as root .. now when I am a regular user and do yo it can't find yo in my path?

    ReplyDelete