windows下angularJs环境搭建和遇到的问题解决

搭建本地开发环境

angular官网社区上说:你应该在自己的电脑上本地开发... 你也应该在本地环境学习 Angular。

本人也认为在本地搭建学习环境--靠谱。所以决定尝试一下。

安照中文社区给的步骤一步一步来。

  1. 新建项目目录(你可以暂时为其取名quickstart,以后再重命名)。

  2. 克隆或者下载《快速起步》种子到你的项目目录。

  3. 安装 npm 包。

  4. 运行npm start来启动例子应用。

安装npm包直接安装node.js的安装包就解决了。

然后执行下面命令:

git clone https://github.com/angular/quickstart.git quickstart
cd quickstart
npm install
npm start

本人机器上执行npm install 会失败,原因是npm需要的依赖找不到,所以,在执行npm install之前,重新设置依赖镜像:

1.通过config命令

npm config set registry https://registry.npm.taobao.org 
npm info underscore (如果上面配置正确这个命令会有字符串response

2.命令行指定

npm --registry https://registry.npm.taobao.org info underscore 

3.编辑 ~/.npmrc 加入下面内容

registry = https://registry.npm.taobao.org

搜索镜像: https://npm.taobao.org

建立或使用镜像,参考: https://github.com/cnpm/cnpmjs.org

然后再进行执行以下命令,完美解决了问题。

参考:

https://cnodejs.org/topic/4f9904f9407edba21468f31e

https://www.angular.cn/docs/ts/latest/guide/setup.html

原文地址:https://www.cnblogs.com/sloveling/p/angular_study.html