搭建环境前提:node和npm要安装好了。
搭建环境步骤:http://www.runoob.com/angularjs2/angularjs2-typescript-setup.html
在搭建环境步骤里,要建立一个package.json文件,里面描述的是一些命令,还有我们angular2项目要引用的一些包。 而包的安装就用到了npm包管理器。
使用 npm install 就能够自动安装我们需要的一些包,不需要我们再一个一个的找包。
package.json包描述的讲解:http://www.jb51.cc/article/p-aulmgesb-bbb.html
tsconfig.json配置文件讲解:https://zhongsp.gitbooks.io/typescript-handbook/content/doc/handbook/Compiler%20Options.html
{ "name": "angular-quickstart","version": "1.0.0","scripts": { "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ","lite": "lite-server","postinstall": "typings install","tsc": "tsc","tsc:w": "tsc -w","typings": "typings" },"license": "ISC","dependencies": { "@angular/common": "2.0.0","@angular/compiler": "2.0.0","@angular/core": "2.0.0","@angular/forms": "2.0.0","@angular/http": "2.0.0","@angular/platform-browser": "2.0.0","@angular/platform-browser-dynamic": "2.0.0","@angular/router": "3.0.0","@angular/upgrade": "2.0.0","core-js": "^2.4.1","reflect-Metadata": "^0.1.3","rxjs": "5.0.0-beta.12","systemjs": "0.19.27","zone.js": "^0.6.23","angular2-in-memory-web-api": "0.0.20","bootstrap": "^3.3.6" },"devDependencies": { "concurrently": "^2.2.0","lite-server": "^2.2.2","typescript": "^2.0.2","typings":"^1.3.2" } }
{ "compilerOptions": { "target": "es5","module": "commonjs","moduleResolution": "node","sourceMap": false,"emitDecoratorMetadata": true,"experimentalDecorators": true,"removeComments": false,"noImplicitAny": false } }
最后不得不吐槽一下环境的搭建:搭建个环境竟然要配置这么多东西,对于一个菜鸟来说,一来就要配置这么多东西。真是懵逼一个啊。出现问题除了卸载重装,删了重新下载就没别的办法了。所以很有必要对这些配置文件里的各个字段的意义去理解一下,最起码知道个大概。一点一点理解,终究会学会的。坚持,angular2
原文链接:https://www.f2er.com/angularjs/147504.html