0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Cygwin + Vagrant + Node.js + Express の環境構築めも

Last updated at Posted at 2018-07-09

備忘用。

##CentOS7.5用のboxセットアップ
mkdir <centos75みたいなの>
vagrant init <centos75みたいなの>

$ cat Vagrantfile
Vagrant.configure("2") do |config|
  config.vm.provider "virtualbox" do |vb|
    vb.gui = false
  end
  config.vm.box = "bento/centos-7.5"
  config.vm.network "public_network"
  config.vm.network "forwarded_port", guest: 3000, host: 3000, id:"http"
  config.vm.network "private_network", ip: "192.168.xxx.yyy"
  config.vm.synced_folder "main","/home/vagrant/main", owner: "vagrant", group: "vagrant", mount_options: ["dmode=777", "fmode=777"]
end

・ユーザ / パスワード は、下記になる。
vagrant / vagrant

##ホスト側の共有フォルダ作成
mkdir main

##box初期化と接続
vagrant up
vagrant ssh

##タイムゾーン変更
sudo timedatectl set-timezone Asia/Tokyo

##CentOS7.5 最新化
sudo yum -y update

##日本語化

sudo localectl set-locale LANG=ja_JP.utf8
sudo localectl set-keymap jp106
source /etc/locale.conf

・確認
echo $LANG
ja_JP.utf8 になっていることを確認。

passwd
なんかのコマンド打って日本語になっていることを確認する。

##VagrantのboxのGuest Additionsのアップデート
共有フォルダのエラー対策

vagrant plugin install vagrant-vbguest
vagrant vbguest

・インストールされたバージョンの確認
vagrant vbguest --status
vagrant reload

##nodeの設定

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
vi .bash_profile
 以下を追加
    # nvm設定
    if [[ -s ~/.nvm/nvm.sh ]];
     then source ~/.nvm/nvm.sh
    fi
source ~/.bash_profile
nvm install v8.11.3
nvm alias default v8.11.3
nvm use v8.11.3

##Express設定

npm i -g express-generator
cd main
express -e (expressのひな型を作成)
ls
npm install express --no-bin-links (必要なmoduleをインポート)
DEBUG=node-test:* npm start (アプリの立ち上げ)

※Windows環境でnpm installでエラーが発生する場合の対処法

npm ERR! EPROTO: protocol error, symlink '../mime/cli.js' -> '/home/vagrant/project/node_modules/.bin/mime'

とでたら
npm install express --no-bin-links
とする。

##Express見る
http://localhost:3000/

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?