简体   繁体   中英

How to run angular 2 application by angular cli

I am trying to create a application using angular 2. I got a sample project folder from github.when I run the application I am getting "Local workspace file ('angular.json') could not be found" error message. How to resolve this issue?

Package.json

{
"name": "demo-app",
"version": "1.0.0",
"author": "Aravind",
"description": "set up files for the first Demo App",
"scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lint": "tslint ./app/**/*.ts -t verbose",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install"
},
"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",
    "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",
    "bootstrap": "^3.3.6"
},
"devDependencies": {
    "concurrently": "^2.2.0",
    "lite-server": "^2.2.0",
    "tslint": "^3.7.4",
    "typescript": "^2.0.2",
    "typings": "^1.0.4"
},
"repository": {}
 }

Looks like your Angular CLI is v6+, and your Angular App is v2. There must be angular-cli.json file in your project. In the latest version of CLI, after v6, config. file is renamed with angular.json with slighter changes. Please create angular.json file and update it accordingly, if this is the case.

Otherwise, just create a new project using ng new <appName> and hit ng serve . As Angular CLI is the latest installed in your machine, so it will create angular.json by default.

Learn more about Angular CLI commands here .

Yes looks like your Angular project is outdated, the newest Angular uses angular.json , not angular-cli.json .

Either ask the creator to update it or do it yourself by following this: https://update.angular.io/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM