8

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

1
  • Did u find a solution to this issue? I am having the same problem. Commented Nov 10, 2017 at 1:04

6 Answers 6

13

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
Sign up to request clarification or add additional context in comments.

2 Comments

ok, i did this. then when I do ng build I get: C:\Users\<user>\AppData\Roaming\npm\node_modules\@angular\cli\models\config\config.js:15 constructor(_configPath, schema, configJson, fallbacks = []) { ^ SyntaxError: Unexpected token = .... <stack trace>
Also, in my project.json, I don't understand why I have a @angular/angular-cli in dependencies and a angular in devdependencies. what's the difference? (besides the difference between dep. vs devdep)
4

If you are on Mac, on the terminal; don't add the '--'. just type [ng version].

Comments

2

Upgrade node and angular-cli

sudo npm install -g n
sudo n latest
sudo npm install -g @angular/cli

Comments

1

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

Comments

1

clean old cli from both local and global account.

remove from local account

npm list
npm uninstall @angular/cli

remove from global account

npm list -g
npm uninstall -g @angular/cli

reinstall in global account

npm install -g @angular/cli

set up environment variable

npm config get prefix
add obtained prefix in windows user environment variables>path

close and open cmd to verify ng v

Comments

-1

Have you installed angular globally as Administrator? Then run ng commands as Administrator too.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.