3

I try to run angular 2 app with ng serve in Linux machine. It is not working. But I tried npm run start command. It is working fine. I got the following message when I tried ng serve command.

As a forewarning, we are moving the CLI npm package to "@angular/cli" 
with the next release,
which will only support Node 6.9 and greater. This package will be 
officially deprecated
shortly after.

To disable this warning use "ng set --global 
warnings.packageDeprecation=false".

You have to be inside an angular-cli project in order to use the 
generate command.

I'm trying this command inside the project folder also.

My package.json file as follows

    {
      "name": "xxxxxx",
      "version": "1.0.0",
      "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
      },
      "private": true,
      "dependencies": {
        "@angular/animations": "^4.1.3",
        "@angular/common": "4.1.3",
        "@angular/compiler": "4.1.3",
        "@angular/core": "4.1.3",
        "@angular/forms": "4.1.3",
        "@angular/http": "4.1.3",
        "@angular/platform-browser": "4.1.3",
        "@angular/platform-browser-dynamic": "4.1.3",
        "@angular/router": "4.1.3",
        "@angular/upgrade": "4.1.3",
        "angular2-jwt": "0.2.3",
        "chart.js": "2.5.0",
        "core-js": "2.4.1",
        "moment": "2.18.1",
        "ng2-charts": "1.5.0",
        "ngx-bootstrap": "1.6.6",
        "primeng": "^4.0.0-rc.3",
        "rxjs": "5.4.0",
        "ts-helpers": "1.1.2",
        "zone.js": "0.8.11"
      },
      "devDependencies": {
        "@angular/cli": "1.0.4",
        "@angular/compiler-cli": "4.1.3",
        "@types/jasmine": "2.5.47",
        "@types/node": "7.0.22",
        "codelyzer": "3.0.1",
        "jasmine-core": "2.6.2",
        "jasmine-spec-reporter": "4.1.0",
        "karma": "1.7.0",
        "karma-chrome-launcher": "2.1.1",
        "karma-cli": "1.0.1",
        "karma-jasmine": "1.1.0",
        "karma-jasmine-html-reporter": "0.2.2",
        "karma-coverage-istanbul-reporter": "1.2.1",
        "protractor": "5.1.2",
        "ts-node": "3.0.4",
        "tslint": "5.3.2",
        "typescript": "2.3.3"
      }

}

I have tried ng generate module [name]. It also not working gives the same above message. What can be the reason for this?

nilashan
  • 690
  • 1
  • 8
  • 30

1 Answers1

0

The error says it all, you are probably at one directory above of your angular app.

Try this

cd my-app
ng serve
Bunyamin Coskuner
  • 8,719
  • 1
  • 28
  • 48
  • I'm within the app directory. where, package.json and other files exists. – nilashan Jun 22 '17 at 07:25
  • 1
    Which version of @angular/cli did you create this application with? It seems so, your server has old angular cli which was just angular-cli. They moved it to @angular project when they released version 1. Make sure your server has new angular cli – Bunyamin Coskuner Jun 22 '17 at 07:26
  • angular-cli: 1.0.0-beta.28.3 – nilashan Jun 22 '17 at 07:28
  • 1
    That's indeed old version. Try this commands in order "npm uninstall -g angular-cli" "npm cache clean" "npm install -g @angular/cli" – Bunyamin Coskuner Jun 22 '17 at 07:29
  • `Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: npm : Depends: node-read-package-json (>= 1.1.0) but it is not going to be installed Depends: node-request (>= 2.25.0) but it is not going to be installed E: Unable to correct problems, you have held broken packages. ` – nilashan Jun 22 '17 at 07:47
  • Faced an issue like this - https://askubuntu.com/questions/764743/unable-to-install-npm-on-ubuntu-14-04-due-to-broken-packages-error – nilashan Jun 22 '17 at 07:48
  • That seems like an issue with ubuntu, not with ng. – Bunyamin Coskuner Jun 22 '17 at 08:30