Angular-cli Angular 4 Starter?

时间:2017-12-11 15:05:06

标签: angular angular-cli

如何获得Angular 4入门者? 我们已经在Angular 4上开发了多个SPA,并希望始终保持一致。 ng new angular-sample --ng4

进行角度5应用。

 "dependencies": {
    "@angular/animations": "^5.0.0",
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/router": "^5.0.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.2",
    "zone.js": "^0.8.14"
  },

6 个答案:

答案 0 :(得分:2)

您需要将angular-cli版本设置为1.4.6。 请按照以下步骤操作。

npm uninstall -g angular-cli npm cache clean npm install -g angular-cli@1.4.6

如果你最近安装了角度cli,那么cli名称可能是“angular / cli”。 为此,您可以使用以下命令。

npm uninstall -g angular/cli npm cache clean npm install -g angular-cli@1.4.6

答案 1 :(得分:1)

如果您想要开箱即用,可以使用Angular CLI version 1.4.6

More on the same

答案 2 :(得分:0)

您无法从最新的角度cli生成ng4应用程序。 --ng4选项现已作为最新删除。

CLI现在只使用ng new project_name创建一个Angular 5项目,您可以将角度版本设置为package.json以下:

  "dependencies": {
    "@angular/common": ">=4.0.0-beta <5.0.0",
    "@angular/compiler": ">=4.0.0-beta <5.0.0",
    "@angular/core": ">=4.0.0-beta <5.0.0",
    "@angular/forms": ">=4.0.0-beta <5.0.0",
    "@angular/http": ">=4.0.0-beta <5.0.0",
    "@angular/platform-browser": ">=4.0.0-beta <5.0.0",
    "@angular/platform-browser-dynamic": ">=4.0.0-beta <5.0.0",
    "@angular/router": ">=4.0.0-beta <5.0.0",
    ...

试了一下,然后就可以了。

尽快更新到ng5。

答案 3 :(得分:0)

在需要更新时始终使用最新的角度cli版本

npm install -g npm

然后

npm cache clean
npm install -g @angular/cli@latest

然后

 "dependencies": {
    "@angular/animations": "^5.0.0",
    "@angular/common": "^5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/router": "^5.0.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.2",
    "zone.js": "^0.8.14"
  }

现在使用,

npm install

如果有任何关于弃用的错误,请将您的代码更新为最新更新

答案 4 :(得分:0)

你可以在NG5上获得初学者回购构建的git pull

[https://github.com/blazehub/ng-cli-starter.git]

该项目预先构建了基础组件,以便开始。

如果你在安装npm时遇到任何错误,只需将你的全局cli升级到package.json中的cli版本。

答案 5 :(得分:0)

您可以使用angular-cli创建角度项目,但是在package.json中指定版本的帮助下,您希望使用哪个角度版本。但是最好使用最新版本的角度总是如此,我没有看到角度4和角度5之间的差异很大我们有一些弃用,我们可以轻松解决它们

 "dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.2",
    "zone.js": "^0.8.14"
  }