1. 程式人生 > >node.js、vue專案建立以及git常用指令總結

node.js、vue專案建立以及git常用指令總結

node.js、vue專案建立以及git常用指令總結

node.js指令

  1. cd… 返回上級

  2. dir 檢視該資料夾下有哪些檔案

  3. node 進入node.js執行環境

  4. .exit 退出node.js執行環境 或者兩側ctrl+c

  5. md folderName 或者mkdir folerName 建立資料夾 完整命令是 md [碟符:][路徑]新路徑名

  6. rd或者rmdir 刪除資料夾,注意只能刪除空的資料夾,如果有子檔案或者子資料夾的時候就會停下來,這時輸入 /s 就可以直接刪除,但是刪除過程中會提示你是否確定刪除,/q 安靜模式,直接刪除

  7. type nul>fileName.txt 建立空檔案

  8. echo content>a.txt 建立非空檔案

  9. del fileName.txt 刪除檔案

  10. rename d:\system\新建資料夾 電影 重新命名資料夾

  11. cls 清屏

  12. node -v 檢視node版本

npm指令

  1. npm -v 檢視npm版本

  2. npm install npm -g npm升級

  3. npm install moduleName 安裝相關模組,例如安裝express模組為:
    npm install express

-g 全域性安裝

  1. 檢視安裝資訊 npm list -g

  2. 更新模組 npm update moduleName

  3. 解除安裝模組 npm uninstall moduleName

  4. 搜尋模組 npm search moduleName

  5. 建立模組 npm init

  6. 檢視npm命令 npm help

  7. npm cache clear 清空npm本地快取

  8. 安裝淘寶映象 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

  1. 安裝淘寶映象
    npm install -g cnpm --registry=http://registry.npm.taobao.org

  2. 安裝vue-cli腳手架構建工具
    npm install -g vue-cli

  3. 新建vue專案資料夾

  4. 初始化vue專案
    vue init webpack + name

  5. 下載node-modules 依賴包
    npm install moduleName

  6. 執行專案
    npm run dev

在專案的構建過程中可以使用通用指令 npm install moduleName 下載所需要的各種模組,包括但不限於juqery,axios等等,具體操作如下:

  1. 引入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資訊配置不唯一,可以根據個人習慣進行相關配置

  1. 引入bootstrap、fontawesome等時可以直接引入檔案,之後再main.js中進行全域性註冊使用

  2. 進行跨域請求的時候,需要使用
    npm install vueresource --save 進行vueresource資源下載,之後再main.js中進行註冊使用,
    之後再config資料夾下找到index.js檔案,進行相關資訊配置
    proxyTable: {
    ‘/ele’:{
    target:‘https://h5.ele.me’,
    changeOrigin:true,
    pathRewrite:{
    ‘^/ele’:’’
    }
    }
    },

vux專案建立

  1. 首先建立專案資料夾 cd到指令目錄
  2. npm install vux --save
  3. npm install vux-loader --save
  4. npm install vue-style-loader
  5. npm install css-loader
  6. npm install less
  7. npm install less-loader
  8. npm run dev
  9. 根據vux官方文件的提示資訊到webpack.base.conf.js進行相關資訊配置

其餘使用中需要下載的依賴項同vue一致

GIT操作指令

  1. git init 初始化

  2. git status 檢視狀態

  3. git add 新增到暫存區

  4. git commit -m content 新增到持久區

  5. git config --global user.email “郵箱地址” 新增賬戶郵箱

  6. git config --global user.name “Your name” 新增賬戶名

  7. git add . 將所有的內容新增儲存

  8. git log 顯示建立資訊

  9. git log --online 將每次的建立資訊分條顯示,顯示的是提交次數以及更改內容,指的都是持久區而非暫存區和工作區

  10. git show id 檢視每次新增的什麼內容

  11. git checkout 檔名 檢查暫存區和持久區(會刪除工作區內容) 回撤

  12. git branch 檢視所有分支

  13. git branch 名字 建立分支

  14. git checkout 名字 切換到指定分支

  15. git merge 分支名 合併 (分支可以看到主支,主支看不到分支)

  16. git reset --hard id 回撤到這個id的地方

  17. git log --graph 顯示所有的操作資訊用圖表顯示

  18. git clone 檔案地址/路徑

  19. git push 上傳

  20. git pull 獲取