Search code examples
angularsystemjspackage.json

ng serve and ng build is not working


I downloaded this github project . this is working fine when I am using NPM START. but when I am using ng serve or ng build this is not working. this is giving the error:

error log

Versions of @angular/compiler-cli and typescript could not be 
determined.The most common reason for this is a broken npm install.
Please make sure your package.json contains both
@angular/compiler-cli and typescript in devDependencies, then 
delete node_modules and package-lock.json (if you have one) 
and run npm install again.

I tried npm install @angular/cli inside the project. ng serve still not working. what I am missing or doing wrong. here is my package.json

package.json

{
"name": "angular-seed",
"description": "An Angular2+PrimeNG+SystemJS seed project",
"private": true,
"scripts": {
  "start": "live-server"
},
"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.0",
  "font-awesome": "^4.6.3",
  "ngx-bootstrap": "^1.7.1",
  "primeng": "^1.0.0-beta.17",
  "rxjs": "5.0.0-beta.12",
  "systemjs": "0.19.37",
  "zone.js": "0.6.21"
},
"devDependencies": {
  "@angular/cli": "^1.5.0",
  "live-server": "1.1.0",
  "typescript": "^2.0.0"
}
}

Solution

  • your start script is live-server in your package.json.

    If you want to work ng serve or ng start then need to generate angular project by angular-cli.This project isn't made by ng-cli that why you can't work.

    Therefore, use ng-cli to make a project and it's easily to set up.Though it's not what you ask but I supported.

    npm install -g @angular/cli
    
    ng help
    #test for your install completely
    
    #if show the help logs
    ng new PROJECT-NAME
    cd PROJECT-NAME
    ng serve
    

    At last, it's impossible to use install angular/cli to start the ng cli , you even didn't got the .angular-cli.json.