node.js、vue專案建立以及git常用指令總結
node.js、vue專案建立以及git常用指令總結
node.js指令
-
cd… 返回上級
-
dir 檢視該資料夾下有哪些檔案
-
node 進入node.js執行環境
-
.exit 退出node.js執行環境 或者兩側ctrl+c
-
md folderName 或者mkdir folerName 建立資料夾 完整命令是 md [碟符:][路徑]新路徑名
-
rd或者rmdir 刪除資料夾,注意只能刪除空的資料夾,如果有子檔案或者子資料夾的時候就會停下來,這時輸入 /s 就可以直接刪除,但是刪除過程中會提示你是否確定刪除,/q 安靜模式,直接刪除
-
type nul>fileName.txt 建立空檔案
-
echo content>a.txt 建立非空檔案
-
del fileName.txt 刪除檔案
-
rename d:\system\新建資料夾 電影 重新命名資料夾
-
cls 清屏
-
node -v 檢視node版本
npm指令
-
npm -v 檢視npm版本
-
npm install npm -g npm升級
-
npm install moduleName 安裝相關模組,例如安裝express模組為:
npm install express
-g 全域性安裝
-
檢視安裝資訊 npm list -g
-
更新模組 npm update moduleName
-
解除安裝模組 npm uninstall moduleName
-
搜尋模組 npm search moduleName
-
建立模組 npm init
-
檢視npm命令 npm help
-
npm cache clear 清空npm本地快取
-
安裝淘寶映象 npm install -g cnpm --registry=https://registry.npm.taobao.org 之後就可以使用cnpn命令
node專案建立方法
1.首先建立一個node專案的資料夾,使用npm init 指令來初始化node專案,這裡注意資料夾名字不能使用中文
2.檔案初識之後可以根據需要下載所需各種模組,這裡指令一般都統一為 npm install moduleName
3.專案建立完成之後,使用 node index(不是唯一指令) 進行啟動
vue專案建立
建立vue專案需要先安裝好node.js
-
安裝淘寶映象
npm install -g cnpm --registry=http://registry.npm.taobao.org -
安裝vue-cli腳手架構建工具
npm install -g vue-cli -
新建vue專案資料夾
-
初始化vue專案
vue init webpack + name -
下載node-modules 依賴包
npm install moduleName -
執行專案
npm run dev
在專案的構建過程中可以使用通用指令 npm install moduleName 下載所需要的各種模組,包括但不限於juqery,axios等等,具體操作如下:
- 引入jquery
npm install jquery --save
之後要進行資訊配置,在build資料夾下找到webpack.base.conf.js,找到
const webpackConfig物件,根據自身需求新增如下命令:
plugins:[
new webpack.ProvidePlugin({
$:‘jquery’,
jquery:‘jquery’,
jQuwey:‘jquery’,
‘winddow.jQuery’:‘jquery’
})
],
注:這裡的node.js資訊配置不唯一,可以根據個人習慣進行相關配置
-
引入bootstrap、fontawesome等時可以直接引入檔案,之後再main.js中進行全域性註冊使用
-
進行跨域請求的時候,需要使用
npm install vueresource --save 進行vueresource資源下載,之後再main.js中進行註冊使用,
之後再config資料夾下找到index.js檔案,進行相關資訊配置
proxyTable: {
‘/ele’:{
target:‘https://h5.ele.me’,
changeOrigin:true,
pathRewrite:{
‘^/ele’:’’
}
}
},
vux專案建立
- 首先建立專案資料夾 cd到指令目錄
- npm install vux --save
- npm install vux-loader --save
- npm install vue-style-loader
- npm install css-loader
- npm install less
- npm install less-loader
- npm run dev
- 根據vux官方文件的提示資訊到webpack.base.conf.js進行相關資訊配置
其餘使用中需要下載的依賴項同vue一致
GIT操作指令
-
git init 初始化
-
git status 檢視狀態
-
git add 新增到暫存區
-
git commit -m content 新增到持久區
-
git config --global user.email “郵箱地址” 新增賬戶郵箱
-
git config --global user.name “Your name” 新增賬戶名
-
git add . 將所有的內容新增儲存
-
git log 顯示建立資訊
-
git log --online 將每次的建立資訊分條顯示,顯示的是提交次數以及更改內容,指的都是持久區而非暫存區和工作區
-
git show id 檢視每次新增的什麼內容
-
git checkout 檔名 檢查暫存區和持久區(會刪除工作區內容) 回撤
-
git branch 檢視所有分支
-
git branch 名字 建立分支
-
git checkout 名字 切換到指定分支
-
git merge 分支名 合併 (分支可以看到主支,主支看不到分支)
-
git reset --hard id 回撤到這個id的地方
-
git log --graph 顯示所有的操作資訊用圖表顯示
-
git clone 檔案地址/路徑
-
git push 上傳
-
git pull 獲取