LoginSignup
6
6

More than 5 years have passed since last update.

MEAN.IO Documentation 解説 - インストール編(Ubuntu)

Posted at

mean.io

MEAN_-_Full-Stack_JavaScript_Using_MongoDB__Express__AngularJS__and_Node_js_.png

以下のドキュメントを参考し、本記事を書きました。
http://learn.mean.io/

Local開発環境構築

vagrant, virtual boxを利用しローカルに開発環境を構築します。vagrant,virtual boxのインストール手順は割愛させていただきます。

Linux(Ubuntu)インストール

# イメージダウンロード
vagrant box add precise32 http://files.vagrantup.com/precise32.box
# 初期化
vagrant init precise32

Vagrantfile編集

config.vm.network "private_network", ip: "192.168.40.10"

サーバー接続

vagrant up
vagrant ssh

PREREQUISITE TECHNOLOGIES

curl, git インストール

sudo apt-get install curl
sudo apt-get install git

Node.jsインストール

curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get update
sudo apt-get install nodejs

mongodbインストール

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/10gen.list
sudo apt-get update
sudo apt-get install mongodb-10gen

起動

sudo service mongodb start

パッケージ管理ツールインストール

sudo npm install -g gulp
sudo npm install -g bower

INSTALLATION

mean cli インストール

sudo npm install -g mean-cli

meanプロジェクト初期化

mean init myApp

※ mean init 実行時以下のエラーが発生した場合

There are 605 files in your ~/.npm owned by root
Please change the permissions by running - chown -R `whoami` ~/.npm

/usr/lib/node_modules/mean-cli/lib/utils.js:67
      throw('ROOT PERMISSIONS IN NPM');
      ^

mean-cliのスクリプトを開き

sudo vi /usr/lib/node_modules/mean-cli/lib/utils.js

init時のパーミッションチェックをコメントアウトする

exports.checkNpmPermission = function (callback){
  var homeDir = process.env[isWin ? 'USERPROFILE' : 'HOME'];
  var findCmd = 'find ' + homeDir +'/.npm ' + '-user root';
/*
  shell.exec(findCmd, function( status, output){
    var hasRootFiles = output.split(/\r\n|\r|\n/).length;
    if (hasRootFiles > 1){
      console.log (chalk.red('There are ' + hasRootFiles + ' files in your ~/.npm owned by root'));
      console.log(chalk.green('Please change the permissions by running -'), 'chown -R `whoami` ~/.npm ');
      throw('ROOT PERMISSIONS IN NPM');
    }
  });
*/
  callback();
};

参考サイト
http://stackoverflow.com/questions/29388995/mean-io-installation-on-windows

この画面が表示されればOK

1__vagrant_precise32_____ssh_.png

meanプロジェクトインストール

cd myApp
sudo npm install

※ npm install 時「npm ERR! Please try running this command again as root/Administrator. ~ 」が発生した場合

sudo chown -R `whoami` ~/.npm

参考サイト
http://qiita.com/Mitsunori_Tsukada/items/7b660d72f2cd42931d19

※ 「{ [Error: Cannot find module '../browser_build/Release/bson'] code: 'MODULE_NOT_FOUND' }」エラー発生時

vi ~/src/node_modules/mongoose/node_modules/mongodb/node_modules/bson/ext/index.js

設定値を変更

//bson = require('../build/Release/bson');
bson = require('../browser_build/bson');

参考サイト
http://stackoverflow.com/questions/28651028/cannot-find-module-build-release-bson-code-module-not-found-js-bson

ブラウザに表示してみよう!

タスクマネージャー起動

gulp
# gulpを使えない場合
node server

host設定

vi ~/myApp/config/env/development.js

hostname追加

module.exports = {
  db: 'mongodb://' + (process.env.DB_PORT_27017_TCP_ADDR || 'localhost') + '/mean-dev',
  debug: true,
  // ここ!!
  hostname: '0.0.0.0',
  logging: {
    format: 'tiny'
  },

ブラウザで表示してみる

MEAN_-_FullStack_JS_-_Development_-_MEAN_-_FullStack_JS_-_Development.png

この画面が表示されればOK!!

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6