in Tips

Getting Yeoman to Work On Ubuntu

One of more popular front end development inventions is the Yeoman scaffolding tool. It has created a buzz on the Internet – for all the good reasons. Yeoman is adept to minifying your style sheets and scripts, as well as scaffolding out an Angular project fast. Think of Yeoman as a jolly little man living inside your command tool, awaiting your requests. For the record, Yeoman is a catch-all phrase for Grunt (automa­tion), Bower (pack­age man­ager), and Yo (scaffolder).

In the official repositories of Ubuntu 14.04, versions 0.10.x of NodeJS are present. But when you try node command in terminal you don’t actually get NodeJS. NodeJS is actually available using nodejs command. So, to setup Yeoman on Ubuntu you need to initially install NodeJS legacy package with apt-get package manager, which is very easy.

First type:

sudo apt-get install nodejs-legacy npm

Because Yeoman depends on ‘node’ legacy binary during installation, npm alone is not really sufficient for installation. That is why you require nodejs-legacy package first.

Install Ruby tools on Ubuntu

Debian GNU/Linux and Ubuntu use the apt package manager. You can use it like this:

sudo apt-get install ruby-full

As of writing, the ruby-full package provides Ruby 1.9.3, which is an old stable release, on Debian and Ubuntu.

Install global npm packages as a regular user

In Ubuntu 14.04, npm installs packages under a ‘prefix’ configuration variable, which defaults to the /usr/lib folder path. This requires from you to use sudo whenever you want to install global npm package. But you can configure ‘prefix’ variable to a point into a user local directory, so as to avoid using sudo.

sudo npm set prefix '/home/yourusername/.npm' –global

Use this command to verify that the above setting has been set.

sudo npm get prefix

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

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

Then restart your terminal session.

Install Yeoman on Ubuntu

Installing from Yeoman this point is nothing but child’s play. Just type:

npm install -g yo

And voila! It is that simple.

To make certain that Yeoman tool has indeed installed successfully, you need to test it. The best way to do a test flight is by navigating into a specific directory – in your terminal – where you would like to start a new project and just type therein:

yo

You will know the Yo installation was successful, when the menu of options including “install a generator” gladly pops up on your terminal. Select the latter “install a generator” option and then type in something like “Webapp”, “Less”, “Ember” or “Angular” at the command prompt. A plethora of generators will pop up. So, aptly choose one and patiently wait for it to install. Yo scaffolding tools are mostly generators, which you should consider as blueprints for your web projects.

If Yeoman, therefore, gets one of the generators it will provide necessary instructions needed to lay some groundwork for your web projects. To know whether Yeoman is working fine on Ubuntu , the installed generator will start pulling down some files with no any issues or errors.

Now you have everything you need to run Yeoman on Ubuntu.

Share this ...Tweet about this on TwitterShare on FacebookEmail this to someoneShare on RedditShare on Google+Share on LinkedInPin on Pinterest
  • PiotrButkiewicz

    bummer, I knew your instructions seemed too good to be true. I got the dreaded permission error codes i’ve been hearing about. maybe you can make sense of this:

    piotr@murph:~/.npm$ npm install -g yo
    npm ERR! Error: EACCES, mkdir ‘/home/piotr/.npm/lib’
    npm ERR! { [Error: EACCES, mkdir ‘/home/piotr/.npm/lib’] errno: 3, code: ‘EACCES’, path: ‘/home/piotr/.npm/lib’ }
    npm ERR!
    npm ERR! Please try running this command again as root/Administrator.

    npm ERR! System Linux 3.18.7-031807-generic
    npm ERR! command “/usr/bin/nodejs” “/usr/bin/npm” “install” “-g” “yo”
    npm ERR! cwd /home/piotr/.npm
    npm ERR! node -v v0.10.25
    npm ERR! npm -v 1.3.10
    npm ERR! path /home/piotr/.npm/lib
    npm ERR! code EACCES
    npm ERR! errno 3
    npm ERR! stack Error: EACCES, mkdir ‘/home/piotr/.npm/lib’
    npm ERR! Error: EACCES, open ‘npm-debug.log’
    npm ERR! { [Error: EACCES, open ‘npm-debug.log’] errno: 3, code: ‘EACCES’, path: ‘npm-debug.log’ }
    npm ERR!
    npm ERR! Please try running this command again as root/Administrator.

    npm ERR! System Linux 3.18.7-031807-generic
    npm ERR! command “/usr/bin/nodejs” “/usr/bin/npm” “install” “-g” “yo”
    npm ERR! cwd /home/piotr/.npm
    npm ERR! node -v v0.10.25
    npm ERR! npm -v 1.3.10
    npm ERR! path npm-debug.log
    npm ERR! code EACCES
    npm ERR! errno 3
    npm ERR! stack Error: EACCES, open ‘npm-debug.log’
    npm ERR!
    npm ERR! Additional logging details can be found in:
    npm ERR! /home/piotr/.npm/npm-debug.log
    npm ERR! not ok code 0
    piotr@murph:~/.npm$

    • amit

      @PiotrButkiewicz:disqus first run sudo chown -R /home/piotr/npm/
      then type your password make sure you are administrator

    • samuel perez

      use sudo su, and try again… it’s suggested to install the lastest version of nodejs and npm, check out the error: npm ERR! node -v v0.10.25, npm ERR! npm -v 1.3.10, so, use NodeSource PPA, for nodejs v 5.x –>

      curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash –

      sudo apt-get install -y nodejs…

  • Borgy Manotoy

    Followed everything from the top, but I am stuck at installing YO. It seems yodoctor command is not found. I successfully installed yeoman-doctor by the way. I am running ubuntu 17 with the latest versions of nodejs and npm. TIA

    borgymanotoy@azeus:~/dev/npm$ npm i -g yo

    > spawn-sync@1.0.15 postinstall /home/borgymanotoy/.npm/lib/node_modules/yo/node_modules/spawn-sync
    > node postinstall

    > yo@2.0.0 postinstall /home/borgymanotoy/.npm/lib/node_modules/yo
    > yodoctor

    sh: 1: yodoctor: not found
    npm ERR! Linux 4.10.0-28-generic
    npm ERR! argv “/usr/bin/nodejs” “/usr/bin/npm” “i” “-g” “yo”
    npm ERR! node v7.10.1
    npm ERR! npm v4.2.0
    npm ERR! file sh
    npm ERR! code ELIFECYCLE
    npm ERR! errno ENOENT
    npm ERR! syscall spawn

    npm ERR! yo@2.0.0 postinstall: `yodoctor`
    npm ERR! spawn ENOENT
    npm ERR!
    npm ERR! Failed at the yo@2.0.0 postinstall script ‘yodoctor’.
    npm ERR! Make sure you have the latest version of node.js and npm installed.
    npm ERR! If you do, this is most likely a problem with the yo package,
    npm ERR! not with npm itself.
    npm ERR! Tell the author that this fails on your system:
    npm ERR! yodoctor
    npm ERR! You can get information on how to open an issue for this project with:
    npm ERR! npm bugs yo
    npm ERR! Or if that isn’t available, you can get their info via:
    npm ERR! npm owner ls yo
    npm ERR! There is likely additional logging output above.

    npm ERR! Please include the following file with any support request:
    npm ERR! /home/borgymanotoy/.npm/_logs/2017-07-28T05_32_28_300Z-debug.log