如何为服务器构建Angular 2.4.4项目

时间:2017-11-08 10:15:20

标签: angular

我的问题是我需要建立项目,但这是第一次,我还没有找到如何创建bulid.json 我的pakage.json

{
  "name": "test",
  "version": "1.0.0",
  "description": "some simple app",
  "scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
    "lite": "lite-server",
    "tsc": "tsc",
    "tsc:w": "tsc -w"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/animations": "^4.4.3",
    "@angular/common": "2.4.4",
    "@angular/compiler": "2.4.4",
    "@angular/core": "2.4.4",
    "@angular/forms": "2.4.4",
    "@angular/http": "2.4.4",
    "@angular/platform-browser": "2.4.4",
    "@angular/platform-browser-dynamic": "2.4.4",
    "@angular/router": "3.4.4",
    "@angular/upgrade": "2.4.4",
    "angular2-bootstrap-switch": "^0.2.3",
    "angular2-in-memory-web-api": "0.0.21",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "css-toggle-switch": "^4.1.0",
    "mydatepicker": "^2.0.31",
    "mydaterangepicker": "^4.1.9",
    "ng2-bootstrap": "1.3.0",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.3",
    "systemjs": "0.20.0",
    "zone.js": "0.7.6",
    "tslint": "^5.7.0"
  },
  "devDependencies": {
    "concurrently": "3.1.0",
    "lite-server": "^2.2.0",
    "typescript": "2.0.3"
  },
  "repository": {}
}

我是Angular 2中的新手,如果我正确理解在Apache上为简单的Web服务器运行网站,我需要构建它,我试图运行

ng build

但告诉我没有安装ng但是如果运行

npm start

网站正在开通并正常运作

1 个答案:

答案 0 :(得分:2)

您需要Angular CLI

npm install -g angular-cli

完成此操作后,您可以运行ng build

阅读文档,它提供了许多有用的信息,包括针对prod / dev等的不同构建环境,运行测试,创建新的组件/指令......

转换为CLI应用程序的有用指南:

https://github.com/asnowwolf/angular-cli/commit/515b57933688b37a389c84ee079d9b840a043666