W13: Interface And Application Programming.

This week I wanted to learn and set up node.js and related framework to prepare for the final project. I also briefly touched Raspberry Pi to migrate the server function from my laptop in the future for more compact and portable projects.

“MEAN" stack
  • node.js
  • mongoDB
  • Angular.js
  • Express
  • Yoeman
    • Bower
    • Yo
    • Grunt
Other libraries
  • jQuery
  • Bootstrap
  • D3.js
Raspberry Pi

Though the result might have been skewed by how I picked up the keywords, I could see interesting trends as below.


1. MEAN Stack 101

What’s MEAN stack?
What Developers Mean When They Build a MEAN Stack
https://www.newspindigital.com/nsd-tech-primer-the-mean-stack-a-k-a-full-stack-javascript/



http://bluefletch.com/blog/why-mean-js-matters-to-enterprise/


How’s the workflow goes?


http://www.kunxi.org/blog/2014/08/adventures-in-the-frontend-wonderland/


Other things I would like to combine this week

D3.js


http://d3js.org/


2. Set up the environment on OS X

Install Node.js

Install MongoDB using MacPorts
Used the tutorial (日本語)http://qiita.com/yoh-nak/items/f0c429f10347ae7ec98b

Tomos-MacBook-Air:~ Tomo$ port install mongodb
Error: Insufficient privileges to write to MacPorts install prefix.
Tomos-MacBook-Air:~ Tomo$ sudo port install mongodb
Password:
--->  Computing dependencies for mongodb
--->  Dependencies to be installed: libpcap openssl pcre bzip2 libedit snappy lzo2
--->  Fetching archive for libpcap
--->  Attempting to fetch libpcap-1.6.2_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/libpcap
--->  Attempting to fetch libpcap-1.6.2_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/libpcap
--->  Installing libpcap @1.6.2_0
--->  Activating libpcap @1.6.2_0
--->  Cleaning libpcap
--->  Fetching archive for openssl
--->  Attempting to fetch openssl-1.0.1j_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/openssl
--->  Attempting to fetch openssl-1.0.1j_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/openssl
--->  Installing openssl @1.0.1j_0
--->  Activating openssl @1.0.1j_0
--->  Cleaning openssl
--->  Fetching archive for bzip2
--->  Attempting to fetch bzip2-1.0.6_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/bzip2
--->  Attempting to fetch bzip2-1.0.6_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/bzip2
--->  Installing bzip2 @1.0.6_0
--->  Activating bzip2 @1.0.6_0
--->  Cleaning bzip2
--->  Fetching archive for libedit
--->  Attempting to fetch libedit-20140620-3.1_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/libedit
--->  Attempting to fetch libedit-20140620-3.1_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/libedit
--->  Installing libedit @20140620-3.1_0
--->  Activating libedit @20140620-3.1_0
--->  Cleaning libedit
--->  Fetching archive for pcre
--->  Attempting to fetch pcre-8.36_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/pcre
--->  Attempting to fetch pcre-8.36_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/pcre
--->  Installing pcre @8.36_0
--->  Activating pcre @8.36_0
--->  Cleaning pcre
--->  Fetching archive for lzo2
--->  Attempting to fetch lzo2-2.08_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/lzo2
--->  Attempting to fetch lzo2-2.08_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/lzo2
--->  Installing lzo2 @2.08_0
--->  Activating lzo2 @2.08_0
--->  Cleaning lzo2
--->  Fetching archive for snappy
--->  Attempting to fetch snappy-1.1.1_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/snappy
--->  Attempting to fetch snappy-1.1.1_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/snappy
--->  Installing snappy @1.1.1_0
--->  Activating snappy @1.1.1_0
--->  Cleaning snappy
--->  Fetching archive for mongodb
--->  Attempting to fetch mongodb-2.6.5_1.darwin_13.x86_64.tbz2 from http://packages.macports.org/mongodb
--->  Attempting to fetch mongodb-2.6.5_1.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/mongodb
--->  Installing mongodb @2.6.5_1
--->  Activating mongodb @2.6.5_1
--->  Cleaning mongodb
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.
Tomos-MacBook-Air:~ Tomo$


Try to launch MongoDB …Failed

Tomos-MacBook-Air:~ Tomo$ mongod
mongod --help for help and startup options
2014-12-02T19:57:10.677-0500 [initandlisten] MongoDB starting : pid=19599 port=27017 dbpath=/data/db 64-bit host=Tomos-MacBook-Air.local
2014-12-02T19:57:10.677-0500 [initandlisten]
2014-12-02T19:57:10.677-0500 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2014-12-02T19:57:10.677-0500 [initandlisten] db version v2.6.5
2014-12-02T19:57:10.677-0500 [initandlisten] git version: nogitversion
2014-12-02T19:57:10.677-0500 [initandlisten] OpenSSL version: OpenSSL 1.0.1j 15 Oct 2014
2014-12-02T19:57:10.677-0500 [initandlisten] build info: Darwin tennine-slave.macports.org 13.2.0 Darwin Kernel Version 13.2.0: Thu Apr 17 23:03:13 PDT 2014; root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2014-12-02T19:57:10.677-0500 [initandlisten] allocator: tcmalloc
2014-12-02T19:57:10.677-0500 [initandlisten] options: {}
2014-12-02T19:57:10.677-0500 [initandlisten] exception in initAndListen: 10296
*********************************************************************
 ERROR: dbpath (/data/db) does not exist.
 Create this directory or give existing directory in --dbpath.
 See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
2014-12-02T19:57:10.677-0500 [initandlisten] dbexit:
2014-12-02T19:57:10.677-0500 [initandlisten] shutdown: going to close listening sockets...
2014-12-02T19:57:10.678-0500 [initandlisten] shutdown: going to flush diaglog...
2014-12-02T19:57:10.678-0500 [initandlisten] shutdown: going to close sockets...
2014-12-02T19:57:10.678-0500 [initandlisten] shutdown: waiting for fs preallocator...
2014-12-02T19:57:10.678-0500 [initandlisten] shutdown: lock for final commit...
2014-12-02T19:57:10.678-0500 [initandlisten] shutdown: final commit...
2014-12-02T19:57:10.678-0500 [initandlisten] shutdown: closing all files...
2014-12-02T19:57:10.678-0500 [initandlisten] closeAllFiles() finished
2014-12-02T19:57:10.678-0500 [initandlisten] dbexit: really exiting now
Tomos-MacBook-Air:~ Tomo$


Initial settings for MongoDB

Tomos-MacBook-Air:~ Tomo$ sudo mkdir /var/lib/mongodb
Tomos-MacBook-Air:~ Tomo$ sudo touch /var/log/mongodb.log

Launch MongoDB Daemon

Tomos-MacBook-Air:~ Tomo$ sudo mongod --dbpath /var/lib/mongodb --logpath /var/log/mongodb.log
2014-12-02T20:00:34.693-0500 log file "/var/log/mongodb.log" exists; moved to "/var/log/mongodb.log.2014-12-03T01-00-34".


Launch MongoDB

Tomos-MacBook-Air:~ Tomo$ mongo
MongoDB shell version: 2.6.5
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
Questions? Try the support group
Server has startup warnings:
2014-12-02T20:00:34.706-0500 [initandlisten]
2014-12-02T20:00:34.706-0500 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
>
>
>
> exit
bye
Tomos-MacBook-Air:~ Tomo$


Install Grunt

Tomos-MacBook-Air:~ Tomo$ sudo npm install -g grunt-cli
Password:
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
grunt-cli@0.1.13 /usr/local/lib/node_modules/grunt-cli
├── resolve@0.3.1
├── nopt@1.0.10 (abbrev@1.0.5)
└── findup-sync@0.1.3 (lodash@2.4.1, glob@3.2.11)
Tomos-MacBook-Air:~ Tomo$

Install Git

Tomos-MacBook-Air:~ Tomo$ sudo port install git
--->  Computing dependencies for git
--->  Dependencies to be installed: curl curl-ca-bundle libidn p5.16-authen-sasl p5.16-digest-hmac p5.16-digest-sha1 perl5.16 gdbm p5.16-gssapi p5.16-error p5.16-net-smtp-ssl p5.16-io-socket-ssl p5.16-net-libidn p5.16-net-ssleay p5.16-term-readkey python27 db48 db_select python_select sqlite3 rsync popt
--->  Fetching archive for curl-ca-bundle
--->  Attempting to fetch curl-ca-bundle-7.39.0_0.darwin_13.noarch.tbz2 from http://packages.macports.org/curl-ca-bundle
--->  Attempting to fetch curl-ca-bundle-7.39.0_0.darwin_13.noarch.tbz2.rmd160 from http://packages.macports.org/curl-ca-bundle
--->  Installing curl-ca-bundle @7.39.0_0
--->  Activating curl-ca-bundle @7.39.0_0
--->  Cleaning curl-ca-bundle
--->  Fetching archive for libidn
--->  Attempting to fetch libidn-1.29_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/libidn
--->  Attempting to fetch libidn-1.29_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/libidn
--->  Installing libidn @1.29_0
--->  Activating libidn @1.29_0
--->  Cleaning libidn
--->  Fetching archive for curl
--->  Attempting to fetch curl-7.39.0_0+ssl.darwin_13.x86_64.tbz2 from http://packages.macports.org/curl
--->  Attempting to fetch curl-7.39.0_0+ssl.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/curl
--->  Installing curl @7.39.0_0+ssl
--->  Activating curl @7.39.0_0+ssl
--->  Cleaning curl
--->  Fetching archive for gdbm
--->  Attempting to fetch gdbm-1.11_1.darwin_13.x86_64.tbz2 from http://packages.macports.org/gdbm
--->  Attempting to fetch gdbm-1.11_1.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/gdbm
--->  Installing gdbm @1.11_1
--->  Activating gdbm @1.11_1
--->  Cleaning gdbm
--->  Fetching archive for perl5.16
--->  Attempting to fetch perl5.16-5.16.3_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/perl5.16
--->  Attempting to fetch perl5.16-5.16.3_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/perl5.16
--->  Installing perl5.16 @5.16.3_0
--->  Activating perl5.16 @5.16.3_0
--->  Cleaning perl5.16
--->  Fetching archive for p5.16-digest-sha1
--->  Attempting to fetch p5.16-digest-sha1-2.130.0_4.darwin_13.x86_64.tbz2 from http://packages.macports.org/p5.16-digest-sha1
--->  Attempting to fetch p5.16-digest-sha1-2.130.0_4.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/p5.16-digest-sha1
--->  Installing p5.16-digest-sha1 @2.130.0_4
--->  Activating p5.16-digest-sha1 @2.130.0_4
--->  Cleaning p5.16-digest-sha1
--->  Fetching archive for p5.16-digest-hmac
--->  Attempting to fetch p5.16-digest-hmac-1.30.0_0.darwin_13.noarch.tbz2 from http://packages.macports.org/p5.16-digest-hmac
--->  Attempting to fetch p5.16-digest-hmac-1.30.0_0.darwin_13.noarch.tbz2.rmd160 from http://packages.macports.org/p5.16-digest-hmac
--->  Installing p5.16-digest-hmac @1.30.0_0
--->  Activating p5.16-digest-hmac @1.30.0_0
--->  Cleaning p5.16-digest-hmac
--->  Fetching archive for p5.16-gssapi
--->  Attempting to fetch p5.16-gssapi-0.280.0_2.darwin_13.x86_64.tbz2 from http://packages.macports.org/p5.16-gssapi
--->  Attempting to fetch p5.16-gssapi-0.280.0_2.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/p5.16-gssapi
--->  Installing p5.16-gssapi @0.280.0_2
--->  Activating p5.16-gssapi @0.280.0_2
--->  Cleaning p5.16-gssapi
--->  Fetching archive for p5.16-authen-sasl
--->  Attempting to fetch p5.16-authen-sasl-2.160.0_0.darwin_13.noarch.tbz2 from http://packages.macports.org/p5.16-authen-sasl
--->  Attempting to fetch p5.16-authen-sasl-2.160.0_0.darwin_13.noarch.tbz2.rmd160 from http://packages.macports.org/p5.16-authen-sasl
--->  Installing p5.16-authen-sasl @2.160.0_0
--->  Activating p5.16-authen-sasl @2.160.0_0
--->  Cleaning p5.16-authen-sasl
--->  Fetching archive for p5.16-error
--->  Attempting to fetch p5.16-error-0.170.220_1.darwin_13.noarch.tbz2 from http://packages.macports.org/p5.16-error
--->  Attempting to fetch p5.16-error-0.170.220_1.darwin_13.noarch.tbz2.rmd160 from http://packages.macports.org/p5.16-error
--->  Installing p5.16-error @0.170.220_1
--->  Activating p5.16-error @0.170.220_1
--->  Cleaning p5.16-error
--->  Fetching archive for p5.16-net-libidn
--->  Attempting to fetch p5.16-net-libidn-0.120.0_4.darwin_13.x86_64.tbz2 from http://packages.macports.org/p5.16-net-libidn
--->  Attempting to fetch p5.16-net-libidn-0.120.0_4.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/p5.16-net-libidn
--->  Installing p5.16-net-libidn @0.120.0_4
--->  Activating p5.16-net-libidn @0.120.0_4
--->  Cleaning p5.16-net-libidn
--->  Fetching archive for p5.16-net-ssleay
--->  Attempting to fetch p5.16-net-ssleay-1.660.0_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/p5.16-net-ssleay
--->  Attempting to fetch p5.16-net-ssleay-1.660.0_0.darwin_13.x86_64.tbz2 from http://lil.fr.packages.macports.org/p5.16-net-ssleay
--->  Attempting to fetch p5.16-net-ssleay-1.660.0_0.darwin_13.x86_64.tbz2 from http://nue.de.packages.macports.org/macports/packages/p5.16-net-ssleay
--->  Fetching distfiles for p5.16-net-ssleay
--->  Attempting to fetch Net-SSLeay-1.66.tar.gz from http://mirrors.ibiblio.org/CPAN/modules/by-module/Net
--->  Verifying checksums for p5.16-net-ssleay
--->  Extracting p5.16-net-ssleay
--->  Applying patches to p5.16-net-ssleay
--->  Configuring p5.16-net-ssleay
--->  Building p5.16-net-ssleay
--->  Staging p5.16-net-ssleay into destroot
--->  Installing p5.16-net-ssleay @1.660.0_0
--->  Activating p5.16-net-ssleay @1.660.0_0
--->  Cleaning p5.16-net-ssleay
--->  Fetching archive for p5.16-io-socket-ssl
--->  Attempting to fetch p5.16-io-socket-ssl-2.5.0_0.darwin_13.noarch.tbz2 from http://packages.macports.org/p5.16-io-socket-ssl
--->  Attempting to fetch p5.16-io-socket-ssl-2.5.0_0.darwin_13.noarch.tbz2.rmd160 from http://packages.macports.org/p5.16-io-socket-ssl
--->  Installing p5.16-io-socket-ssl @2.5.0_0
--->  Activating p5.16-io-socket-ssl @2.5.0_0
--->  Cleaning p5.16-io-socket-ssl
--->  Fetching archive for p5.16-net-smtp-ssl
--->  Attempting to fetch p5.16-net-smtp-ssl-1.10.0_0.darwin_13.noarch.tbz2 from http://packages.macports.org/p5.16-net-smtp-ssl
--->  Attempting to fetch p5.16-net-smtp-ssl-1.10.0_0.darwin_13.noarch.tbz2.rmd160 from http://packages.macports.org/p5.16-net-smtp-ssl
--->  Installing p5.16-net-smtp-ssl @1.10.0_0
--->  Activating p5.16-net-smtp-ssl @1.10.0_0
--->  Cleaning p5.16-net-smtp-ssl
--->  Fetching archive for p5.16-term-readkey
--->  Attempting to fetch p5.16-term-readkey-2.320.0_1.darwin_13.x86_64.tbz2 from http://packages.macports.org/p5.16-term-readkey
--->  Attempting to fetch p5.16-term-readkey-2.320.0_1.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/p5.16-term-readkey
--->  Installing p5.16-term-readkey @2.320.0_1
--->  Activating p5.16-term-readkey @2.320.0_1
--->  Cleaning p5.16-term-readkey
--->  Fetching archive for db_select
--->  Attempting to fetch db_select-0.1_2.darwin_13.noarch.tbz2 from http://packages.macports.org/db_select
--->  Attempting to fetch db_select-0.1_2.darwin_13.noarch.tbz2.rmd160 from http://packages.macports.org/db_select
--->  Installing db_select @0.1_2
--->  Activating db_select @0.1_2
--->  Cleaning db_select
--->  Fetching archive for db48
--->  Attempting to fetch db48-4.8.30_4.darwin_13.x86_64.tbz2 from http://packages.macports.org/db48
--->  Attempting to fetch db48-4.8.30_4.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/db48
--->  Installing db48 @4.8.30_4
--->  Activating db48 @4.8.30_4
--->  Cleaning db48
--->  Fetching archive for python_select
--->  Attempting to fetch python_select-0.3_4.darwin_13.noarch.tbz2 from http://packages.macports.org/python_select
--->  Attempting to fetch python_select-0.3_4.darwin_13.noarch.tbz2.rmd160 from http://packages.macports.org/python_select
--->  Installing python_select @0.3_4
--->  Activating python_select @0.3_4
--->  Cleaning python_select
--->  Fetching archive for sqlite3
--->  Attempting to fetch sqlite3-3.8.7.1_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/sqlite3
--->  Attempting to fetch sqlite3-3.8.7.1_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/sqlite3
--->  Installing sqlite3 @3.8.7.1_0
--->  Activating sqlite3 @3.8.7.1_0
--->  Cleaning sqlite3
--->  Fetching archive for python27
--->  Attempting to fetch python27-2.7.8_3.darwin_13.x86_64.tbz2 from http://packages.macports.org/python27
--->  Attempting to fetch python27-2.7.8_3.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/python27
--->  Installing python27 @2.7.8_3
--->  Activating python27 @2.7.8_3

To make python 2.7 the default (i.e. the version you get when you run 'python'), please run:

sudo port select --set python python27

--->  Cleaning python27
--->  Fetching archive for popt
--->  Attempting to fetch popt-1.16_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/popt
--->  Attempting to fetch popt-1.16_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/popt
--->  Installing popt @1.16_0
--->  Activating popt @1.16_0
--->  Cleaning popt
--->  Fetching archive for rsync
--->  Attempting to fetch rsync-3.1.1_0.darwin_13.x86_64.tbz2 from http://packages.macports.org/rsync
--->  Attempting to fetch rsync-3.1.1_0.darwin_13.x86_64.tbz2.rmd160 from http://packages.macports.org/rsync
--->  Installing rsync @3.1.1_0
--->  Activating rsync @3.1.1_0

To use the rsyncd server you must copy /opt/local/etc/rsyncd.conf.example to rsyncd.conf and add your
modules there. See 'man rsyncd.conf' for more information.

--->  Cleaning rsync
--->  Fetching archive for git
--->  Attempting to fetch git-2.1.2_0+credential_osxkeychain+doc+pcre+perl5_16+python27.darwin_13.x86_64.tbz2 from http://packages.macports.org/git
--->  Attempting to fetch git-2.1.2_0+credential_osxkeychain+doc+pcre+perl5_16+python27.darwin_13.x86_64.tbz2 from http://lil.fr.packages.macports.org/git
--->  Attempting to fetch git-2.1.2_0+credential_osxkeychain+doc+pcre+perl5_16+python27.darwin_13.x86_64.tbz2 from http://nue.de.packages.macports.org/macports/packages/git
--->  Fetching distfiles for git
--->  Attempting to fetch git-2.1.2.tar.gz from https://www.kernel.org/pub/software/scm/git/
--->  Attempting to fetch git-manpages-2.1.2.tar.gz from https://www.kernel.org/pub/software/scm/git/
--->  Attempting to fetch git-htmldocs-2.1.2.tar.gz from https://www.kernel.org/pub/software/scm/git/
--->  Verifying checksums for git
--->  Extracting git
--->  Applying patches to git
--->  Configuring git
--->  Building git
--->  Staging git into destroot
--->  Installing git @2.1.2_0+credential_osxkeychain+doc+pcre+perl5_16+python27
--->  Activating git @2.1.2_0+credential_osxkeychain+doc+pcre+perl5_16+python27
--->  Cleaning git
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.
Tomos-MacBook-Air:~ Tomo$


Install Bower

Tomos-MacBook-Air:~ Tomo$ sudo npm i -g bower
Password:
/usr/local/bin/bower -> /usr/local/lib/node_modules/bower/bin/bower
bower@1.3.12 /usr/local/lib/node_modules/bower
├── is-root@1.0.0
├── junk@1.0.0
├── stringify-object@1.0.0
├── abbrev@1.0.5
├── which@1.0.7
├── chmodr@0.1.0
├── osenv@0.1.0
├── opn@1.0.0
├── archy@0.0.2
├── rimraf@2.2.8
├── lru-cache@2.5.0
├── bower-endpoint-parser@0.2.2
├── bower-logger@0.2.2
├── graceful-fs@3.0.5
├── lockfile@1.0.0
├── nopt@3.0.1
├── retry@0.6.0
├── tmp@0.0.23
├── q@1.0.1
├── semver@2.3.2
├── fstream@1.0.3 (inherits@2.0.1)
├── request-progress@0.3.0 (throttleit@0.0.2)
├── p-throttler@0.1.0 (q@0.9.7)
├── shell-quote@1.4.2 (array-filter@0.0.1, array-reduce@0.0.0, array-map@0.0.0, jsonify@0.0.0)
├── bower-json@0.4.0 (intersect@0.0.3, deep-extend@0.2.11, graceful-fs@2.0.3)
├── promptly@0.2.0 (read@1.0.5)
├── chalk@0.5.0 (escape-string-regexp@1.0.2, ansi-styles@1.1.0, supports-color@0.2.0, strip-ansi@0.3.0, has-ansi@0.1.0)
├── mkdirp@0.5.0 (minimist@0.0.8)
├── fstream-ignore@1.0.1 (inherits@2.0.1, minimatch@1.0.0)
├── bower-config@0.5.2 (osenv@0.0.3, graceful-fs@2.0.3, optimist@0.6.1)
├── mout@0.9.1
├── glob@4.0.6 (inherits@2.0.1, minimatch@1.0.0, once@1.3.1)
├── tar-fs@0.5.2 (pump@0.3.5, tar-stream@0.4.7)
├── cardinal@0.4.0 (redeyed@0.4.4)
├── request@2.42.0 (caseless@0.6.0, json-stringify-safe@5.0.0, forever-agent@0.5.2, aws-sign2@0.5.0, stringstream@0.0.4, oauth-sign@0.4.0, tunnel-agent@0.4.0, node-uuid@1.4.1, qs@1.2.2, mime-types@1.0.2, bl@0.9.3, http-signature@0.10.0, tough-cookie@0.12.1, hawk@1.1.1, form-data@0.1.4)
├── bower-registry-client@0.2.1 (graceful-fs@2.0.3, request-replay@0.2.0, lru-cache@2.3.1, async@0.2.10, mkdirp@0.3.5, request@2.27.0)
├── decompress-zip@0.0.8 (nopt@2.2.1, mkpath@0.1.0, touch@0.0.2, readable-stream@1.1.13, binary@0.3.0)
├── update-notifier@0.2.0 (semver-diff@0.1.0, string-length@0.1.2, configstore@0.3.1, latest-version@0.2.0)
├── inquirer@0.7.1 (figures@1.3.5, mute-stream@0.0.4, through@2.3.6, lodash@2.4.1, rx@2.3.18, readline2@0.1.0, cli-color@0.3.2)
├── insight@0.4.3 (object-assign@1.0.0, async@0.9.0, chalk@0.5.1, os-name@1.0.1, lodash.debounce@2.4.1, tough-cookie@0.12.1, configstore@0.3.1, inquirer@0.6.0)
└── handlebars@2.0.0 (optimist@0.3.7, uglify-js@2.3.6)
Tomos-MacBook-Air:~ Tomo$
├── junk@1.0.0


Install Express

Tomos-MacBook-Air:~ Tomo$ sudo npm install -g express
Password:
express@4.10.4 /usr/local/lib/node_modules/express
├── merge-descriptors@0.0.2
├── utils-merge@1.0.0
├── fresh@0.2.4
├── cookie@0.1.2
├── escape-html@1.0.1
├── range-parser@1.0.2
├── cookie-signature@1.0.5
├── finalhandler@0.3.2
├── vary@1.0.0
├── media-typer@0.3.0
├── methods@1.1.0
├── parseurl@1.3.0
├── serve-static@1.7.1
├── content-disposition@0.5.0
├── path-to-regexp@0.1.3
├── depd@1.0.0
├── qs@2.3.3
├── on-finished@2.1.1 (ee-first@1.1.0)
├── debug@2.1.0 (ms@0.6.2)
├── send@0.10.1 (destroy@1.0.3, ms@0.6.2, mime@1.2.11)
├── proxy-addr@1.0.4 (forwarded@0.1.0, ipaddr.js@0.1.5)
├── etag@1.5.1 (crc@3.2.1)
├── type-is@1.5.3 (mime-types@2.0.3)
└── accepts@1.1.3 (negotiator@0.4.9, mime-types@2.0.3)
Tomos-MacBook-Air:~ Tomo$ 


Install Angular.js (exists)

Tomos-MacBook-Air:~ Tomo$ sudo npm install -g angularjs
Password:
angularjs@0.0.1 /usr/local/lib/node_modules/angularjs


Difference betweenMean.io and Mean.js

Details are explained here.
http://stackoverflow.com/questions/23199392/difference-between-mean-js-and-mean-io
http://blog.meanjs.org/post/76726660228/forking-out-of-an-open-source-conflict

Image from: http://www.creativeworkline.com/2014/05/meanio-vs-meanjs-comparison/



Install the MEAN CLI …Failed.

http://learn.mean.io/ Prerequisites 
Error. The advice did not work. http://stackoverflow.com/questions/22152162/npm-cannot-install-dependencies-attempt-to-unlock-something-which-hasnt-been

Tomos-MacBook-Air:~ Tomo$ sudo chown -R 'Tomo' ~/.npm
Tomos-MacBook-Air:~ Tomo$ sudo chown -R 'Tomo' /usr/local/lib/node_modules

Tomos-MacBook-Air:bin Tomo$ sudo npm install -g mean-cli
\
> mean-cli@0.9.7 preinstall /usr/local/lib/node_modules/mean-cli
> node ./scripts/preinstall

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied

node.js:815
    var cwd = process.cwd();
                      ^
Error: EACCES, permission denied
    at Function.startup.resolveArgv0 (node.js:815:23)
    at startup (node.js:58:13)
    at node.js:906:3
npm ERR! Darwin 13.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "mean-cli"
npm ERR! node v0.10.33
npm ERR! npm  v2.1.10
npm ERR! code ELIFECYCLE

npm ERR! mean-cli@0.9.7 preinstall: `node ./scripts/preinstall`
npm ERR! Exit status 8
npm ERR!
npm ERR! Failed at the mean-cli@0.9.7 preinstall script 'node ./scripts/preinstall'.
npm ERR! This is most likely a problem with the mean-cli package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./scripts/preinstall
npm ERR! You can get their info via:
npm ERR!     npm owner ls mean-cli
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/local/bin/npm-debug.log
Tomos-MacBook-Air:bin Tomo$


Install Yoeman …Failed

Tomos-MacBook-Air:~ Tomo$ sudo npm install -g yo
Password:
/usr/local/bin/yo -> /usr/local/lib/node_modules/yo/cli.js

> yo@1.3.3 postinstall /usr/local/lib/node_modules/yo
> yodoctor

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
sh: yodoctor: command not found
npm ERR! Darwin 13.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "yo"
npm ERR! node v0.10.33
npm ERR! npm  v2.1.10
npm ERR! code ELIFECYCLE

npm ERR! yo@1.3.3 postinstall: `yodoctor`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the yo@1.3.3 postinstall script 'yodoctor'.
npm ERR! 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 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!     /Users/Tomo/npm-debug.log


Troubleshooting

I’ve got the same error when I tried to install mean.io and mean.js(Yeoman).

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied

Some articles suggested su command to get the root access but did not work in my case.
—unsafe-perm also did not work.
Finally it worked with the symlink workaround.
http://stackoverflow.com/questions/20881075/npm-install-g-yo-command-gives-err-yo1-1-0-postinstall-node-scripts-doct/20974081#20974081

Tomos-MacBook-Air:~ Tomo$ sudo ln -s /usr/local/bin/node /usr/bin/node


Install Yoeman (Mean.js) …Success

Tomos-MacBook-Air:~ Tomo$ sudo npm install -g yo
/usr/bin/yo -> /usr/lib/node_modules/yo/cli.js

> yo@1.3.3 postinstall /usr/lib/node_modules/yo
> yodoctor

[Yeoman Doctor] Everything looks all right!

yo@1.3.3 /usr/lib/node_modules/yo
├── is-root@1.0.0
├── sudo-block@1.0.0
├── fullname@1.0.0
├── opn@1.0.0
├── underscore.string@2.4.0
├── async@0.9.0
├── yeoman-character@1.0.0 (supports-color@1.2.0)
├── yeoman-doctor@1.1.1 (user-home@1.1.0)
├── string-length@1.0.0 (strip-ansi@2.0.0)
├── nopt@3.0.1 (abbrev@1.0.5)
├── chalk@0.5.1 (escape-string-regexp@1.0.2, ansi-styles@1.1.0, supports-color@0.2.0, has-ansi@0.1.0, strip-ansi@0.3.0)
├── findup@0.1.5 (commander@2.1.0, colors@0.6.2)
├── multiline@1.0.1 (strip-indent@1.0.0)
├── shelljs@0.3.0
├── yosay@1.0.0 (ansi-regex@1.1.0, ansi-styles@1.1.0, strip-ansi@2.0.0, pad-component@0.0.1, word-wrap@0.1.3, minimist@1.1.0, taketalk@0.1.1)
├── update-notifier@0.2.2 (is-npm@1.0.0, semver-diff@2.0.0, latest-version@1.0.0)
├── lodash@2.4.1
├── configstore@0.3.1 (object-assign@0.3.1, osenv@0.1.0, graceful-fs@3.0.5, uuid@1.4.2, mkdirp@0.5.0, js-yaml@3.0.2)
├── insight@0.4.3 (object-assign@1.0.0, os-name@1.0.1, lodash.debounce@2.4.1, tough-cookie@0.12.1, request@2.49.0, inquirer@0.6.0)
├── yeoman-environment@1.1.1 (log-symbols@1.0.1, diff@1.2.0, untildify@1.0.0, text-table@0.2.0, debug@2.1.0, grouped-queue@0.3.0, mem-fs@1.0.0, glob@4.3.1, inquirer@0.8.0)
└── yeoman-generator@0.17.7 (dargs@2.1.0, diff@1.2.0, class-extend@0.1.1, rimraf@2.2.8, github-username@1.0.0, text-table@0.2.0, mime@1.2.11, debug@1.0.4, grouped-queue@0.3.0, isbinaryfile@2.0.3, run-async@0.1.0, cross-spawn@0.2.3, mkdirp@0.5.0, glob@4.3.1, iconv-lite@0.4.5, findup-sync@0.1.3, file-utils@0.2.1, request@2.49.0, download@1.0.7, cheerio@0.17.0, gruntfile-editor@0.2.0, inquirer@0.7.3)
Tomos-MacBook-Air:~ Tomo$


Now I have Yeoman with:
     yo - scaffold generator
     Grunt - task runner
     Bower - JS library dependencies management


Follow this tutorial from now - D3.js on Angular.js using Yeoman (Mean.js) http://www.robinwieruch.de/d3-on-angular-seed/


Install generator-angular

Tomos-MacBook-Air:~ Tomo$ sudo npm install -g generator-angular
Password:
generator-karma@0.8.3 /usr/lib/node_modules/generator-karma
├── underscore@1.7.0
└── yeoman-generator@0.17.7 (dargs@2.1.0, diff@1.2.0, class-extend@0.1.1, rimraf@2.2.8, github-username@1.0.0, text-table@0.2.0, underscore.string@2.4.0, mime@1.2.11, async@0.9.0, chalk@0.5.1, nopt@3.0.1, cross-spawn@0.2.3, isbinaryfile@2.0.3, run-async@0.1.0, debug@1.0.4, mkdirp@0.5.0, shelljs@0.3.0, grouped-queue@0.3.0, glob@4.3.1, iconv-lite@0.4.5, findup-sync@0.1.3, request@2.49.0, file-utils@0.2.1, lodash@2.4.1, download@1.0.7, cheerio@0.17.0, gruntfile-editor@0.2.0, inquirer@0.7.3)

generator-angular@0.10.0 /usr/lib/node_modules/generator-angular
├── chalk@0.4.0 (has-color@0.1.7, ansi-styles@1.0.0, strip-ansi@0.1.1)
├── yosay@0.2.1 (pad-component@0.0.1, word-wrap@0.1.3, minimist@0.0.9)
├── wiredep@1.8.6 (propprop@0.3.0, minimist@1.1.0, lodash@2.4.1, chalk@0.5.1, through2@0.6.3, glob@4.3.1, bower-config@0.5.2)
└── yeoman-generator@0.16.0 (dargs@0.1.0, diff@1.0.8, debug@0.7.4, class-extend@0.1.1, rimraf@2.2.8, findup-sync@0.1.3, text-table@0.2.0, mime@1.2.11, async@0.2.10, mkdirp@0.3.5, isbinaryfile@2.0.3, shelljs@0.2.6, glob@3.2.11, underscore.string@2.3.3, iconv-lite@0.2.11, lodash@2.4.1, request@2.30.0, file-utils@0.1.5, download@0.1.19, cheerio@0.13.1, inquirer@0.4.1)
Tomos-MacBook-Air:~ Tomo$


3. Hello World” stuff on MEAN Stack

Create New Project Template using Yo
(Tutorials: (in Japanese) https://www.engcafe.tv/news/2014082613751/3/)

Tomos-MacBook-Air:~ Tomo$ cd documents
Tomos-MacBook-Air:documents Tomo$ mkdir htmaa
Tomos-MacBook-Air:documents Tomo$ cd htmaa
Tomos-MacBook-Air:htmaa Tomo$ mkdir d3-angular
Tomos-MacBook-Air:htmaa Tomo$ cd d3-angular/
Tomos-MacBook-Air:d3-angular Tomo$ pwd
/Users/Tomo/documents/htmaa/d3-angular
Tomos-MacBook-Air:d3-angular Tomo$ yo angular d3test

I selected several options about Sass, Bootstrap and other modules. 




Tomos-MacBook-Air:d3-angular Tomo$ pwd
/Users/Tomo/documents/htmaa/d3-angular
Tomos-MacBook-Air:d3-angular Tomo$ grunt serve



Create New Project with Yo (without Compass)

Tomos-MacBook-Air:htmaa Tomo$ mkdir d3-angular-test
Tomos-MacBook-Air:htmaa Tomo$ cd d3-angular-test/
Tomos-MacBook-Air:d3-angular-test Tomo$ yo angular d3test

<OMITTED>



Launch node.js web server with Grunt

Tomos-MacBook-Air:d3-angular-test Tomo$ grunt serve



Browser window below automatically launched successfully!


Grunt -
     automatically launches node.js web server
     monitors the file changes (just like hg does). We do not have to hit reload when we change source codes and html files
     compiles Sass and CoffeeScript files in realtime


Set up D3.js + Angular.js project

Install d3.js using bower

Tomos-MacBook-Air:d3-angular-test Tomo$ bower install d3 --save
bower not-cached    git://github.com/mbostock/d3.git#*
bower resolve       git://github.com/mbostock/d3.git#*
bower download      https://github.com/mbostock/d3/archive/v3.4.13.tar.gz
bower extract       d3#* archive.tar.gz
bower resolved      git://github.com/mbostock/d3.git#3.4.13
bower install       d3#3.4.13

d3#3.4.13 bower_components/d3
Tomos-MacBook-Air:d3-angular-test Tomo$

Include d3.js

I created a new factory called d3Service.js under app/scripts/services/ directory.

Tomos-MacBook-Air:d3-angular-test Tomo$ yo angular:factory d3Service
   create app/scripts/services/d3service.js
   create test/spec/services/d3service.js
Tomos-MacBook-Air:d3-angular-test Tomo$





Change d3Service.js


Change app.js


Create d3 directive

Tomos-MacBook-Air:d3-angular-test Tomo$ yo angular:directive simpleLineChart
   create app/scripts/directives/simplelinechart.js
   create test/spec/directives/simplelinechart.js
Tomos-MacBook-Air:d3-angular-test Tomo$

Add d3 styles on app/styles/main.css

Change index.html

I added  <div simple-line-chart></div> as the place holder of the d3service. The browser window was successfully reloaded when I saved the index.html.




4. Applications

Create Application which connect by FirmATA with AVR

Install generator-angular-fullstack

Tomos-MacBook-Air:d3-angular-test Tomo$ sudo npm install -g generator-angular-fullstack
Password:
-
> yo@1.3.3 postinstall /usr/lib/node_modules/generator-angular-fullstack/node_modules/yo
> yodoctor

[Yeoman Doctor] Everything looks all right!

generator-angular-fullstack@2.0.13 /usr/lib/node_modules/generator-angular-fullstack
├── chalk@0.4.0 (ansi-styles@1.0.0, has-color@0.1.7, strip-ansi@0.1.1)
├── wiredep@0.4.2 (lodash@1.3.1, chalk@0.1.1)
├── yeoman-generator@0.17.7 (dargs@2.1.0, diff@1.2.0, class-extend@0.1.1, rimraf@2.2.8, text-table@0.2.0, underscore.string@2.4.0, github-username@1.0.0, mime@1.2.11, async@0.9.0, debug@1.0.4, grouped-queue@0.3.0, chalk@0.5.1, nopt@3.0.1, cross-spawn@0.2.3, isbinaryfile@2.0.3, run-async@0.1.0, mkdirp@0.5.0, shelljs@0.3.0, iconv-lite@0.4.5, glob@4.3.1, findup-sync@0.1.3, file-utils@0.2.1, download@1.0.7, request@2.49.0, lodash@2.4.1, cheerio@0.17.0, gruntfile-editor@0.2.0, inquirer@0.7.3)
├── yo@1.3.3 (is-root@1.0.0, sudo-block@1.0.0, fullname@1.0.0, opn@1.0.0, underscore.string@2.4.0, yeoman-doctor@1.1.1, yeoman-character@1.0.0, string-length@1.0.0, chalk@0.5.1, async@0.9.0, multiline@1.0.1, nopt@3.0.1, findup@0.1.5, shelljs@0.3.0, yosay@1.0.0, update-notifier@0.2.2, lodash@2.4.1, configstore@0.3.1, insight@0.4.3, yeoman-environment@1.1.1)
└── generator-ng-component@0.0.10
Tomos-MacBook-Air:d3-angular-test Tomo$


Use previous HEMS project as a framework

It took around 10 minutes to complete the set up process.
http://www.atmarkit.co.jp/ait/articles/1410/15/news174_3.html (in Japanese)






Tomos-MacBook-Air:hemsjs Tomo$ yo angular-fullstack:endpoint thermoHygroHistory
? What will the url of your endpoint to be? /api/thermoHygroHistorys
   create server/api/thermoHygroHistory/index.js
   create server/api/thermoHygroHistory/thermoHygroHistory.controller.js
   create server/api/thermoHygroHistory/thermoHygroHistory.model.js
   create server/api/thermoHygroHistory/thermoHygroHistory.socket.js
   create server/api/thermoHygroHistory/thermoHygroHistory.spec.js

Tomos-MacBook-Air:hemsjs Tomo$ yo angular-fullstack:endpoint airConditioner
? What will the url of your endpoint to be? /api/airConditioners
   create server/api/airConditioner/index.js
   create server/api/airConditioner/airConditioner.controller.js
   create server/api/airConditioner/airConditioner.model.js
   create server/api/airConditioner/airConditioner.socket.js
   create server/api/airConditioner/airConditioner.spec.js

Tomos-MacBook-Air:hemsjs Tomo$ yo angular-fullstack:route heatIndex
? Where would you like to create this route? client/app/
? What will the url of your route be? /heatIndex
   create client/app/heatIndex/heatIndex.js
   create client/app/heatIndex/heatIndex.controller.js
   create client/app/heatIndex/heatIndex.controller.spec.js
   create client/app/heatIndex/heatIndex.css
   create client/app/heatIndex/heatIndex.html

Tomos-MacBook-Air:hemsjs Tomo$ yo angular-fullstack:route airConditioner
? Where would you like to create this route? client/app/
? What will the url of your route be? /airConditioner
   create client/app/airConditioner/airConditioner.js
   create client/app/airConditioner/airConditioner.controller.js
   create client/app/airConditioner/airConditioner.controller.spec.js
   create client/app/airConditioner/airConditioner.css
   create client/app/airConditioner/airConditioner.html
Tomos-MacBook-Air:hemsjs Tomo$

http://www.atmarkit.co.jp/ait/articles/1411/19/news053.html
omos-MacBook-Air:hemsjs Tomo$ git init
Initialized empty Git repository in /Users/Tomo/Documents/htmaa/hemsjs/.git/
Tomos-MacBook-Air:hemsjs Tomo$ git clone https://github.com/iwanaga/hemsjs.git
Cloning into 'hemsjs'...
remote: Counting objects: 129, done.
remote: Total 129 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (129/129), 54.95 KiB | 0 bytes/s, done.
Resolving deltas: 100% (18/18), done.
Checking connectivity... done.
Tomos-MacBook-Air:hemsjs Tomo$





Delete wrong .git

Tomos-MacBook-Air:hemsjs Tomo$ rm -rf .git




Now it is time to run MEAN stack on Raspberry Pi

http://www.raspberrypi.org/introducing-raspberry-pi-model-b-plus/

I set up Raspberry Pi Model B+ without keyboard burning an image to a microSD card. Pinging from my laptop to Pi was successful. Now it is time to install node.js and other peripheral software on it.
Tutorial: MEAN Raspberry Pi Home Web Server (Part 3) http://notejs.com/?p=252


Other resources (some in Japanese)
D3.js on Angular.js using Yeoman (Mean.js) http://www.robinwieruch.de/d3-on-angular-seed/
D3をAngular.jsでラップしてみよう http://qiita.com/Quramy/items/b701b824c2f42c683aa7