2.环境配置

作者: DejavuMoments | 来源:发表于2016-04-17 14:08 被阅读88次

开发工具

  • Git && GitHub(这个需要配置好)
  • NodeJS && NPM(官网可以安装)
  • Visual Studio Code(很赞的编辑器)
  • Chrome(推荐,Angular2在IE上有时候没有效果)

搭建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:

  • npm start - runs the compiler and a server at the same time, both in "watch mode".
  • npm run tsc - runs the TypeScript compiler once.
  • npm run tsc:w - runs the TypeScript compiler in watch mode; the process keeps running, awaiting changes to TypeScript files and re-compiling when it sees them.
  • npm run lite - runs the lite-server, a light-weight, static file server, written and maintained by
    John Papa and
    Christopher Martin
    with excellent support for Angular apps that use routing.
  • npm run typings - runs the typings tool.
  • npm run postinstall - called by npm automatically after it successfully completes package installation. This script installs the TypeScript definition files this app requires.

Here are the test related scripts:

  • npm test - compiles, runs and watches the karma unit tests
  • npm webdriver:update - ONE TIME update for protractor end-to-end (e2e) tests
  • npm run e2e - run protractor e2e tests, written in JavaScript (*e2e-spec.js)

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!

相关文章

  • 2.环境配置

    开发工具 Git && GitHub(这个需要配置好) NodeJS && NPM(官网可以安装) Visual ...

  • 2. Redis 环境配置

    1.. 安装 redis 简单配置 设置任何 host 可以连接编辑 redis.conf 找到 bind 127...

  • 2021-11-07

    配置解析 1.核心配置文件 2.环境配置(environments) mybatis可以适应多种环境,但是要记住:...

  • iOS Scheme多环境运行配置

    多环境运行的配置流程 1.配置多个环境的scheme 2.配置多个.xcconfig 选择Target -> Ne...

  • 2.配置 Android 开发环境

    brew install android-sdk vi ~/.bash_profile export ANDROI...

  • 2. PHP开发环境配置

    要开发和运行PHP网页,需要在您的计算机系统上安装三个重要软件(组件)。 Web服务器 - PHP几乎可以运行在所...

  • 2.环境搭建与配置

    安装node稳定版本,当前为12.16.3通过nvm可以管理本地的node版本(安装比较麻烦,涉及网络问题) 通过...

  • Linux上配置openjdk,maven,git的环境变量

    1.配置openjdk的环境变量 2.配置maven的环境变量 《maven官网》 3.配置git的环境变量 《引...

  • 1.配置MySQL环境变量

    1.配置MySQL环境变量 2.验证是否配置成功

  • zookeeper集群的安装

    配置环境准备 (环境按照本地虚拟机进行配置,真实线上环境酌情修改)采用三台机器ip设置为 1.配置网络 2.配置防...

网友评论

    本文标题:2.环境配置

    本文链接:https://www.haomeiwen.com/subject/hypolttx.html