Dan Vrajmas
Dan Vrajmas

Reputation: 93

How to Build Angular 2.4.4 project for server

My problem is that i need to build project but is the first time and i diden't find how to create bulid.json My 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": {}
}

I'm new in Angular 2 and if i correctly understand that to run site on Apache for simple web servers i need to build it i tried to run

ng build

but tells me that ng is not installed but if run

npm start

site is opening and works correctly

Upvotes: 0

Views: 213

Answers (1)

Ric
Ric

Reputation: 13248

You'll need Angular CLI

npm install -g angular-cli

Once you have this, you can run ng build.

Read the documentation, it provides a lot of useful information including targeting different build environments for prod/dev etc, running tests, creating new components/directives...

A useful guide to converting to a CLI app:

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

Upvotes: 2

Related Questions