Angular: Zero to Hero我爱编程

2.环境配置

2016-04-17  本文已影响88人  DejavuMoments

开发工具

搭建QuickStart应用

在环境配置方面,官方在GitHub上给出了一个 QuickStart 的应用框架,可以作为基本的应用框架来使用,用起来很方便。点击下载QuickStart源码 开始吧。

为了方便,我直接粘贴在这里,有删减,翻译水平有限就不翻译了......

Angular 2 QuickStart Source

This repository holds the TypeScript source code of the angular.io quickstart,
the foundation for most of the documentation samples and potentially a good starting point for your application.

It's been extended with testing support so you can start writing tests immediately.

This is not the perfect arrangement for your application. It is not designed for production.
It exists primarily to get you started quickly with learning and prototyping in Angular 2

We are unlikely to accept suggestions about how to grow this QuickStart into something it is not.
Please keep that in mind before posting issues and PRs.

Create a new project based on the QuickStart

Clone this repo into new project folder (e.g., my-proj).

git clone  https://github.com/angular/quickstart  my-proj
cd my-proj

We have no intention of updating the source on angular/quickstart.
Discard everything "git-like" by deleting the .git folder.

rm -rf .git

Create a new git repo

You could start writing code now and throw it all away when you're done.
If you'd rather preserve your work under source control, consider taking the following steps.

Initialize this project as a local git repo and make the first commit:

git init
git add .
git commit -m "Initial commit"

Create a remote repository for this project on the service of your choice.

Grab its address (e.g. https://github.com/<my-org>/my-proj.git) and push the local repo to the remote.

git remote add origin <repo-address>
git push -u origin master

Install npm packages

Install the npm packages described in the package.json and verify that it works:

Attention Windows Developers: You must run all of these commands in administrator mode

npm install
npm start

The npm start command first compiles the application,
then simultaneously re-compiles and runs the lite-server.
Both the compiler and the server watch for file changes.

Shut it down manually with Ctrl-C.

You're ready to write your application.

npm scripts

We've captured many of the most useful commands in npm scripts defined in the package.json:

Here are the test related scripts:

Shut it down manually with Ctrl-C.

git clone 比较慢 npm install.png Paste_Image.png

用npm安装出现问题,换用 cnpm 试试

cnpm install.png 安装ing 安装成功,WARN可以暂时忽略。。。

使用 npm start 开始吧!

Paste_Image.png Paste_Image.png

这时会自动启动浏览器,修改代码会自动刷新(真贴心),省去了配置 gup、grunt的麻烦。

默认界面

至此,开发环境配置好了!Happy coding!

上一篇 下一篇

猜你喜欢

热点阅读