環境准備:
WebStorm開發工具 https://pan.baidu.com/s/1o8maQLG 提取密碼(加群獲取599606903)
nodejs https://nodejs.org/en/download/
angular-cli
window
1.WebStorm安裝
2.nodejs安裝
(1)下載Windows版的Nodejs,進行按照提示安裝即可
如果正常顯示版本號,即安裝成功。
(2)nodejs配置
Nodejs安裝完成之后,默認會將node.exe的路徑,添加到系統的環境變量中,如果沒有請手動添加。除此之外還要進行其他的配置
1、配置prefix和cache目錄
d:\node
npm config set prefix "d:\node\node_global"
npm config set cache "d:\node\node_cache"
2、配置環境變量
計算機->屬性->高級系統設置->環境變量
在系統變量中設置node_path
新建 變量名 NODE_PATH 變量值 D:\node\node_global\node_modules
這個值就是上一步中,通過 “npm config set prefix” 設置的值。可以,用下面命令查看
npm config get prefix
在用戶變量修改path
path D:\node\node_global\
3、配置sass_binary
angular cli 是要依賴node-sass的,默認情況下,不會像其它包一樣直接下載,而是要下載后進行編譯的。在Windows下,首先要通過git下載win32-x64-51_binding.node,但是不知道是被牆還是什么原因,下不下來,就會導致后面的編譯出錯,以及提示找不到python和Visual Studio的問題,手動下載相應的版本https://github.com/sass/node-sass/releases/
將下載的binding.node放到指定目錄,例如:
D:\node\darwin-x64-11_binding.node
配置路徑:用過命令配置
npm config set sass_binary_site “https://npm.taobao.org/mirrors/node-sass/” //使用阿里的鏡像
npm config set sass_binary_path “D:\node\darwin-x64-11_binding.node”
(3)安裝工具包
1、全局安裝阿里cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org
2、全局安裝typescript
npm install -g typescript typings
3、全局安裝angular-cli
npm install -g @angular/cli
創建工程
1、打開webStorm新建angular cli工程
運行: