linux下前端node部署操作
## 1.安装git略过(其实我没装过...)
## 2.git --version查看版本
## 3.初始化 git init
## 4.稍微设置一下git的name和email
git config --global user.name "robsky"
git config --global user.email "110@110.com"
查看
git config --global user.name
git config --global user.email
## 5.node环境
下载node 6.x版本
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
然后yum install -y nodejs
node和npm安装完毕
可以用node -v和npm -v查看版本
## 6.clone代码
git clone -b release/1.0 http://110.110.110.110/xiangmu/xiangmu.git
其中-b是指定分支,release/1.0是分支名,后边是项目地址,会clone到当前目录下
## 7.代码更新
git配置文件是.npmrc文件,内容为(主要是npm私服地址)
registry=http://110.110.110.110/repository/npm-group/
.npmrc文件就放在~下,查看所有文件命令为 ls -a
这里写了一个脚本
#!/bin/bash
cd /usr/local/www/html/xiangmu-xiangmu-xiangmu/xiangmu
git pull
npm install
npm install we-ui we-common we-vue-common we-http we-event
npm run build
ps aux |grep node |grep -v grep |awk '{print $2}' |xargs kill -9
node server.js &
#npm run dev &**
再设置个别名,破费!
## 一些操作
修改git地址
查看所有远程仓库 git remote
查看某(origin)仓库地址 git remote show origin
修改某(origin)仓库地址 git remote set-url origin http://110.110.110.110/xiangmu/xiangmu.git
或者修改项目目录下的.git下的config文件中的url为新地址
修改成功后pull代码时会提示输入新地址的账号密码,很烦人怎么办呢
切换到根目录,执行git config --global credential.helper store
之后根目录下.gitconfig文件中会出现
[credential]
helper = store
然后正常输入用户名和密码就会记住密码了