一锰扶、安裝環(huán)境搭建
1.node.js的安裝
確保安裝的是最新版的node.js, 運行cmd命令 node -v可查詢安裝node.js版本寝受,npm -v 可查詢npm的安裝版本坷牛,npm是跟隨者node.js一同安裝的
2. 安裝yeoman
yeoman分為三個模塊 yo bower grunt,運行命令npm install -g yo bower grunt-cli 進行全局安裝
最新版本的yeomen使用gulp替代了grunt
輸入yo --version ,bower --version可以查看安裝版本
輸入grunt顯示如下信息說明grunt-cli安裝成功:
grunt-cli: The grunt command line interface (v1.2.0)
Fatal error: Unable to find local grunt.
If you're seeing this message, grunt hasn't been installed locally to
your project. For more information about installing and configuring grunt,
please see the Getting Started guide:
http://gruntjs.com/getting-started
3.安裝Angularjs生成器
npm install -g grnerator-webapp
二很澄、 創(chuàng)建項目
創(chuàng)建并切換到新文件夾
mkdir my-angular && cd my-angular
執(zhí)行命令 yo 或yo webapp 或 yo angular
根據(jù)提示選擇安裝
運行命令啟動程序 grunt serve 或grunt serve --force
在angularjs項目中會存在使用gulp替代grunt的現(xiàn)象京闰,是因為官方逐漸使用gulp替代grunt
此時在項目中不會生成gruntfile.js文件在package.json中也沒有自動構建grunt安裝
使用此命令將generator-webapp的版本降低到0.6.2就可以了
npm install generator-webapp@v0.6.2