NodeJs 在window中安裝使用

weixin_33982670發表於2018-06-05

Nodejs:

官網下載長期版本zip格式解壓

D:\Program Files\nodejs

檢視版本

D:\Git\SpringBootDemo (master)                                                                                          
$ node -v                                                                                                               
v8.11.2                                                                                                                 
                                                                                                                        
D:\Git\SpringBootDemo (master)                                                                                          
$ npm -v                                                                                                                
5.6.0  

在此路徑下建兩個資料夾node_global和node_cache

更改npm全域性模組和cache預設安裝位置

D:\Git\SpringBootDemo (master)                                                                                          
$  npm config set prefix "D:\Program Files\nodejs\node_global"                                                          
                                                                                                                        
D:\Git\SpringBootDemo (master)                                                                                          
$  npm config set cache "D:\Program Files\nodejs\node_cache"                                                            
                                                                                                                        
D:\Git\SpringBootDemo (master)                                                                                          
$  npm config get prefix                                                                                                
D:\Program Files\nodejs\node_global                                                                                     
                                                                                                                        
D:\Git\SpringBootDemo (master)                                                                                          
$ npm config get cache                                                                                                  
D:\Program Files\nodejs\node_cache   

新增系統變數:

Path新增:

D:\Program Files\nodejs
D:\Program Files\nodejs\node_global

新增NODE_PATH

D:\Program Files\nodejs\node_global\node_modules

淘寶映象:

D:\Program Files
$ npm config set registry https://registry.npm.taobao.org

D:\Program Files
$ npm config get registry
https://registry.npm.taobao.org/

通過cnpm使用:

D:\Program Files
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
npm WARN deprecated socks@1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
D:\Program Files\nodejs\node_global\cnpm -> D:\Program Files\nodejs\node_global\node_modules\cnpm\bin\cnpm
+ cnpm@6.0.0
added 917 packages in 35.536s

D:\Program Files
$ cnpm config get registry
https://registry.npm.taobao.org/

安裝最常用express模組:

D:\Git\SpringBootDemo (master)                                                                                          
$ npm install express -g                                                                                                
+ express@4.16.3                                                                                                        
added 50 packages in 6.291s                                                                                             
                                                                                                                        
D:\Git\SpringBootDemo (master)                                                                                          
$ npm root -g                                                                                                           
D:\Program Files\nodejs\node_global\node_modules    

安裝vue腳手架:

D:\Program Files
$ npm install --global vue-cli
npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
D:\Program Files\nodejs\node_global\vue -> D:\Program Files\nodejs\node_global\node_modules\vue-cli\bin\vue
D:\Program Files\nodejs\node_global\vue-list -> D:\Program Files\nodejs\node_global\node_modules\vue-cli\bin\vue-list
D:\Program Files\nodejs\node_global\vue-init -> D:\Program Files\nodejs\node_global\node_modules\vue-cli\bin\vue-init
+ vue-cli@2.9.6
added 252 packages in 19.487s

D:\Program Files
$ vue -V
2.9.6

安裝vue-cli腳手架構建工具
vue-cli 提供一個官方命令列工具,可用於快速搭建大型單頁應用。該工具提供開箱即用的構建工具配置,帶來現代化的前端開發流程。只需幾分鐘即可建立並啟動一個帶熱過載、儲存時靜態檢查以及可用於生產環境的構建配置的專案:

$ npm install vue-cli -g

安裝webpack

 npm install webpack -g
 
 One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
 - webpack-cli (https://github.com/webpack/webpack-cli)
   The original webpack full-featured CLI.
 - webpack-command (https://github.com/webpack-contrib/webpack-command)
   A lightweight, opinionated webpack CLI.
We will use "npm" to install the CLI via "npm install -D".
Which one do you like to install (webpack-cli/webpack-command):

npm install webpack-cli -g

開始安裝webpack提示必須安裝webpack-cli,然後再次安裝webpack-cli

D:\Git
$ webpack -v
4.11.0

 

https://nodejs.org/zh-cn/download/

https://blog.csdn.net/henery_002/article/details/78016575

http://www.cnblogs.com/PeunZhang/p/5629329.html

https://www.liaoxuefeng.com/wiki/001434446689867b27157e896e74d51a89c25cc8b43bdb3000/001470969077294a6455fc9cd1f48b69f82cd05e7fa9b40000

https://my.oschina.net/summerdays/blog/835233

https://segmentfault.com/a/1190000007998600

https://www.cnblogs.com/weiqinl/p/7503123.html

相關文章