Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular cli ng commands not working

Windows server 2012 R2

node v4.7.4 npm v4.3.0

I cannot do a "ng serve": "/c/Users//AppData/Roaming/npm/ng: No such file or directory"

I also cannot do "npm start": "Unexpected token {" then a huge call stack.

I have tried using various versions of node/npm/cli etc... I can't get anywhere.

my app's project.json file:

{
  "name": "my-proj",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "start": "ng serve --env=source",
    "build": "ng build",
    "build-replace": "ng build --env=replace",
    "lint": "tslint \"src/**/*.ts\"",
    "test": "ng test",
    "pree2e": "webdriver-manager update",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/compiler-cli": "2.2.4",
    "@angular/core": "2.0.0",
    "@angular/flex-layout": "2.0.0-beta.3",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/material": "2.0.0-alpha.10",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/router": "3.0.0",
    "angular2-select": "1.0.0-alpha.12",
    "core-js": "2.4.1",
    "hammerjs": "2.0.8",
    "jsrsasign": "6.1.1",
    "jwt-decode": "2.1.0",
    "lodash": "4.16.4",
    "material-design-lite": "1.2.1",
    "moment": "2.15.1",
    "ng2-pagination": "0.5.1",
    "ng2-translate": "4.0.0",
    "normalize.css": "4.2.0",
    "primeng": "1.0.0-rc.6",
    "rxjs": "5.0.0-beta.12",
    "ts-helpers": "1.1.1",
    "xmljson": "0.2.0",
    "zone.js": "0.6.23"
  },
  "devDependencies": {
    "@types/jasmine": "2.2.30",
    "@types/lodash": "4.14.37",
    "angular-cli": "1.0.0-beta.16",
    "codelyzer": "0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "2.0.0",
    "karma-cli": "1.0.1",
    "karma-jasmine": "1.0.2",
    "karma-remap-istanbul": "0.2.1",
    "protractor": "4.0.9",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.2"
  }
}

For what it's worth on my OSX machine, I am able to do npm start just fine:

Here are the version on my OSX:

ng -v gives me:

angular-cli: 1.0.0-beta.16

node: 6.9.4

os: darwin x64

npm -v gives me:

3.10.10

like image 512
default_noob_network Avatar asked Feb 16 '17 22:02

default_noob_network


3 Answers

Try to upgrade your cli version there are lots of changes happened after beta16. You can do it like this;

npm uninstall -g angular-cli @angular/cli
npm cache clean
npm install -g @angular/cli@latest
like image 81
Mertcan Diken Avatar answered Nov 17 '22 01:11

Mertcan Diken


Upgrade node and angular-cli

sudo npm install -g n
sudo n latest
sudo npm install -g @angular/cli
like image 29
İzzet Altınel Avatar answered Nov 17 '22 01:11

İzzet Altınel


Solution:

update .npmrc file at C:\Users\{USERNAME}

with the below line

prefix=${APPDATA}\npm

This post helped me: http://itechiesol.blogspot.co.za/2017/07/angular-cli-ng-command-is-not-working.html

like image 40
Stephan Avatar answered Nov 17 '22 00:11

Stephan