检查角度2版本并得到此错误

时间:2017-09-11 05:48:48

标签: angular command-line

在我发出命令ng -v之后,我得到了这个答案。有人可以解释这里有什么问题吗?任何角度安装问题?

enter image description here

2 个答案:

答案 0 :(得分:0)

首先确保将angular cli安装为

npm install -g @angular/cli

-g使其全局安装,然后您可以运行命令。

ng -v

或者你可以在devDependencies json中更新package.json中的@ angular / cli

"angular-cli": "anything"

"@angular/cli": "1.3.2"

答案 1 :(得分:0)

DEMO目录中的package.json在dev依赖项中没有列出angular@cli

...
"devDependencies": {
    "@angular/cli": "^1.3.0", // <--- Here is the local project package.
    "@angular/compiler-cli": "^4.0.0",
    "@types/highcharts": "^5.0.4",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.2.0",
    "webpack-bundle-analyzer": "^2.8.2"
  }
...

您应该安装本地和全球@angular/cli软件包。

使用npm install -g @angular/cli@latestnpm install @angular/cli@latest --save-dev

安装软件包

顺便说一下,当您安装angular/@cli并使用ng new命令时,它会自动为您的项目下载所有依赖项,包括@angular/cli