Windows環境下的NodeJS+NPM的安裝和配置css
一、安裝NodeJS
官網地址: http://nodejs.cn/download/
下載相應的安裝包, 安轉.
二、檢查npm是否安裝
以下圖:
因爲新版的NodeJS已經集成了npm,因此以前npm也一併安裝好了。能夠使用cmd命令行中鍵入 npm -v查看npm版本號,進行檢查是否安裝成功.
若沒有安裝npm
安裝淘寶鏡像 :npm install
npm install -g cnpm --registry=https://registry.npm.taobao.orgnode
淘寶鏡像安裝更快方法:
將.npmrc 文件放在本電腦C:UsersAdministrator 路徑中去
.npmrc 文件內容爲:
registry=https://registry.npm.taobao.org/
ELECTRON_MIRROR=http://npm.taobao.org/mirrors...
SASS_BINARY_SITE=http://npm.taobao.org/mirrors...web
安裝Angular CLInpm
$ npm install -g @angular/cli瀏覽器
新建Angular項目sass
D:angularTest>ng new myProj
ng new myProj --style=scss / --style=sass ,--less(樣式文件格式)
--routing(會在app文件中生成app-routing.module.ts配置文件)
即:ng new myProj --routing=true --style=less
用webstrom打開新建 myProj項目app
再一次npm install
最後啓動項目npm start
瀏覽器運行http://localhost:4200/便可完成less
經常使用於新建的指令
ng generate class my-new-class // 新建 class
ng generate component my-new-component // 新建組件
ng generate directive my-new-directive // 新建指令
ng generate enum my-new-enum // 新建枚舉
ng generate module my-new-module // 新建模塊
ng generate pipe my-new-pipe // 新建管道
ng generate service my-new-service // 新建服務electron
能夠簡寫成:命令行
ng g cl my-new-class // 新建 classng g c my-new-component // 新建組件ng g d my-new-directive // 新建指令ng g e my-new-enum // 新建枚舉ng g m my-new-module // 新建模塊ng g p my-new-pipe // 新建管道ng g s my-new-service // 新建服務