为 Aurelia-cli 设置环境解释
- 操作系统: Mac OS X 10.11(因为我们使用的是 Vagrant,所以应该在 Windows / Linux 上运行)
- Vagrant 1.8.4 已安装
- 主机操作系统上的目录结构(Mac OS):
- 启动虚拟机 ($ ==终端提示)
- 在 Mac OS 终端中
$cd /path/to/project/vagrant
$vagrant up
- 下载 CentOS 7 vagrant box,运行配置脚本
- 在 Mac OS 终端外部启动 VM 窗口
- 完成所有操作后,使用 gui 登录 VM
- 用户:流浪汉
- PW:流浪汉
- 启动 X Windows:
$startx
(启动 Gnome UI)
- 设置 VM
- 启动终端窗口(应用程序下拉菜单/实用程序)
- 设置 sudo 运行
npm
- 获取 npm 的路径:
$which npm
(/opt/node-v6.4.0-linux-x64/bin) - 添加到 visudo“secure_path”
$sudo visudo
(需要 Vi / Vim 的基础知识)- 输入
i
进入插入模式 - 使用箭头键导航到“secure_path”行
- 将“:/ opt/node-v6.4.0-linux-x64/bin”附加到“secure_path”
- 输入
esc
退出插入模式 - 输入“:wq”来编写更改并退出 Vi
- 获取 npm 的路径:
- 更新 npm,修复 aurelia cli 中的关键错误
$npm install npm -g
- 全局安装 aurelia cli
$npm install aurelia-cli -g
- 启动/停止 VM
- 在 Mac OS 终端中
$cd /path/to/project/vagrant
(如果你还没有使用 Vagrantfile 的目录)$vagrant halt
(保留所有文件,关闭 GUI,关闭 VM)$vagrant up
(重启虚拟机,准备好后通过 GUI 登录)$vagrant destroy
(需要再次下载所有内容,你的本地文件将被删除。使用此功能从头开始。)
现在,你已准备好使用 Aurelia CLI 开始构建你的网站!
Vagrantfile
Vagrant.configure("2") do |config| config.vm.box = "centos/7" config.vm.hostname = "dev" config.vm.provider "virtualbox" do |vb| vb.gui = true vb.cpus = "4" vb.memory = "3092" end # Networking config.vm.network "private_network", ip: "192.168.0.3" config.vm.network :forwarded_port, guest: 80, host: 80 # nginx config.vm.network :forwarded_port, guest: 9000, host: 9000 # au run config.vm.network :forwarded_port, guest: 3001, host:3001 # BrowserSynch # Shares config.vm.synced_folder "../provision", "/home/vagrant/provision" # Provision config.vm.provision "shell", path: "provision.sh" end
provision.sh
HOME=/home/vagrant NODE=node-v6.4.0-linux-x64 EPEL=epel-release-latest-7.noarch.rpm ATOM=atom.x86_64 echo "************************************" echo "Provisioning virtual machine..." echo "************************************" sudo cd $HOME echo "***********************" echo "Updating yum..." echo "***********************" sudo yum clean all sudo yum -y install deltarpm yum-utils sudo yum -y update --exclude=kernel* echo "***********************" echo "Updating yum, installing Dev Tools..." echo "***********************" sudo yum -y groupinstall "Base" sudo yum -y groupinstall "GNOME Desktop" sudo yum -y groupinstall "Development Tools" echo "***********************" echo "Installing tools..." echo "***********************" sudo yum install -y git tar gcc vim unzip wget curl tree nginx if [ -d "/opt/$NODE" ] then echo "**********************************" echo "Node already installed..." echo "**********************************" else echo "**********************************" echo "Installing Node and update npm..." echo "**********************************" sudo cp /home/vagrant/provision/packages/$NODE.tar.xz /opt sudo tar -xpf /opt/$NODE.tar.xz -C /opt sudo echo "export PATH=\"$PATH:/opt/$NODE/bin\"" >> $HOME/.bash_profile sudo echo "export PATH=\"$PATH:/opt/$NODE/bin\"" >> /root/.bash_profile sudo source $HOME/.bash_profile fi echo "**********************************" echo "Installing Atom..." echo "**********************************" sudo rpm -ivh /home/vagrant/provision/packages/$ATOM.rpm echo "******************************" echo "Installing EPEL..." echo "******************************" wget -P /etc/yum.repos.d http://dl.fedoraproject.org/pub/epel/$EPEL sudo rpm -ivh /etc/yum.repos.d/$EPEL echo "***********************" echo "Git setup..." echo "***********************" git config --global user.email "your@email.com" git config --global user.name "Your Name" git config --global github.user "Username" echo "***********************" echo "Don't forget to:" echo "sudo visudo" echo "Append npm path to secure_path: /opt/$NODE/bin" echo "sudo npm install npm -g" echo "sudo npm install aurelia-cli -g" echo "***********************" echo "*********************************" echo "VM Provisioning Complete!" echo "*********************************"