准备工作
- 安装nodejs
官网下载nodejs安装包,地址http://nodejs.cn/download/ - 修改nodejs默认的缓存文件地址,命令
设置全局模块存放路径;命令npm config set cache "D:\software\nodejs\node_cache"
npm config set prefix "D:\software\nodejs\node_global"
- 用npm安装typescript和typings,因为据说angular-cli是用typescript写的,所以要先装这两个:
npm install -g typescript typings
安装angular-cli:
npm install -g @angular/cli
如果你之前安装失败过,最好在安装angular-cli之前先卸载干净,用以下两句:
npm uninstall -g @angular/cli
npm cache clean
新建angular项目
ng new boboBlog
如果提示ng命令不存在,需要把node_global目录添加到环境变量中,path中加上下面路径
D:\software\nodejs\node_global