shivam SHARMA
shivam SHARMA

Reputation: 11

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"
}
}

Upvotes: 1

Views: 18403

Answers (4)

Sergio Prats
Sergio Prats

Reputation: 1213

I have had this project after trying to install bootstrap on an existing project. After much trying, and since this project was under version control Github, I did the following steps:

  • Deleted the project folder.
  • Created the project again
  • Verified that the ng build was working again
  • Run the git stash command to restore the original versioned files.
  • Run npm install
  • Run npm build

This way the project was saved "the hard way".

Upvotes: 0

Rach Chen
Rach Chen

Reputation: 1392

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.

Upvotes: 3

realharry
realharry

Reputation: 1575

I don't see @angular/compiler-cli in your "devDependencies". Try

npm i --save-dev @angular/compiler-cli

(Unfortunately, your angular versions are pretty old. The versions across all angular packages in an app have to be compatible. It's best just to put this line, "@angular/compiler-cli": "^2.0.0".)

You can remove @angular/cli from package.json. And, make sure you have globally installed angular cli. Try

ng --version
tsc --version

to make sure you have the necessary tools installed.

Upvotes: 0

Rowel de Guzman
Rowel de Guzman

Reputation: 176

I thinks this is because you are using systemJs and not Angular CLI app

take a look here on how to use angular CLI https://github.com/angular/angular-cli

@angular/cli is not the only needed when you need to run in ng serve theres a lot more. :D happy coding :-)

Upvotes: 0

Related Questions