如何使用 Angular v4.x 安装 Angular-CLI [英] How to install Angular-CLI with Angular v4.x
问题描述
我已经使用这个命令安装了 Angular-CLI
I've installed Angular-CLI using this command
npm install -g @angular/cli
但我意识到它已经安装了 Angular v5.1.3,但我需要使用 Angular 4.x.
but I've realized that it has installed Angular v5.1.3 but I need to use Angular 4.x.
如何使用最新版本的 Angular 4.x 安装最新版本的 Angular-CLI?
How can I install the last version of Angular-CLI with the last version of Angular 4.x?
推荐答案
我认为降级您的 cli 不是一个好主意,因为他们正在修复很多错误.您可以在 package.json 文件中指定您的角度.不要依赖于你的 cli.
I think downgrade your cli is not good idea becuase they are fixing lots of bug. You can specific your angular in package.json file. don't depend on your cli.
首先从您的 cli 安装最新版本.然后在 package.json 的dependencies"部分指定您想要的版本.例如,如果你想要 Angular 4.3.4,那么你可以像
First install latest version from your cli. Then Specify the version you want in the 'dependencies' section of your package.json. For example if you want Angular 4.3.4 then you can edit you package.json file like
"dependencies": {
"@angular/animations": "^4.3.4",
"@angular/common": "^4.3.4",
"@angular/compiler": "^4.3.4",
"@angular/core": "^4.3.4",
"@angular/forms": "^4.3.4",
"@angular/http": "^4.3.4",
"@angular/platform-browser": "^4.3.4",
"@angular/platform-browser-dynamic": "^4.3.4",
"@angular/router": "^4.3.4",
...........................
...........................
}
还要更改您的devDependencies
"devDependencies": {
"@angular/compiler-cli": "^4.3.4",
"@angular/language-service": "^4.3.4",
.............
}
现在运行 npm install
now run npm install
npm install
安装完成后,你应该通过 ng -v
命令看到你的版本
After finishing install you should see your version by ng -v
command like this
Angular CLI: 1.6.3
Node: 9.3.0
OS: linux x64
Angular: 4.4.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, tsc-wrapped
@angular/cli: 1.6.3
@angular-devkit/build-optimizer: 0.0.38
@angular-devkit/core: 0.0.25
@angular-devkit/schematics: 0.0.48
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.3
@schematics/angular: 0.1.13
@schematics/schematics: 0.0.13
typescript: 2.4.2
webpack: 3.10.0
这篇关于如何使用 Angular v4.x 安装 Angular-CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!